2020-03-19 02:36:31 +00:00
|
|
|
// +build !plan9,!windows
|
2018-11-27 21:52:20 +00:00
|
|
|
|
|
|
|
package osfs
|
|
|
|
|
|
|
|
import (
|
2020-03-19 02:36:31 +00:00
|
|
|
"os"
|
|
|
|
|
2019-07-31 16:45:42 +00:00
|
|
|
"golang.org/x/sys/unix"
|
2018-11-27 21:52:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (f *file) Lock() error {
|
|
|
|
f.m.Lock()
|
|
|
|
defer f.m.Unlock()
|
|
|
|
|
2019-07-31 16:45:42 +00:00
|
|
|
return unix.Flock(int(f.File.Fd()), unix.LOCK_EX)
|
2018-11-27 21:52:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *file) Unlock() error {
|
|
|
|
f.m.Lock()
|
|
|
|
defer f.m.Unlock()
|
|
|
|
|
2019-07-31 16:45:42 +00:00
|
|
|
return unix.Flock(int(f.File.Fd()), unix.LOCK_UN)
|
2018-11-27 21:52:20 +00:00
|
|
|
}
|
2020-03-19 02:36:31 +00:00
|
|
|
|
|
|
|
func rename(from, to string) error {
|
|
|
|
return os.Rename(from, to)
|
|
|
|
}
|