2020-04-30 10:02:15 +08:00
|
|
|
// +build !plan9,!windows
|
2019-10-29 05:10:20 +08:00
|
|
|
|
|
|
|
package osfs
|
|
|
|
|
|
|
|
import (
|
2020-04-30 10:02:15 +08:00
|
|
|
"os"
|
|
|
|
|
2019-10-29 05:10:20 +08:00
|
|
|
"golang.org/x/sys/unix"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (f *file) Lock() error {
|
|
|
|
f.m.Lock()
|
|
|
|
defer f.m.Unlock()
|
|
|
|
|
|
|
|
return unix.Flock(int(f.File.Fd()), unix.LOCK_EX)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *file) Unlock() error {
|
|
|
|
f.m.Lock()
|
|
|
|
defer f.m.Unlock()
|
|
|
|
|
|
|
|
return unix.Flock(int(f.File.Fd()), unix.LOCK_UN)
|
|
|
|
}
|
2020-04-30 10:02:15 +08:00
|
|
|
|
|
|
|
func rename(from, to string) error {
|
|
|
|
return os.Rename(from, to)
|
|
|
|
}
|