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