2021-08-30 17:18:50 +02:00
|
|
|
// +build !plan9,!windows,!js
|
2019-10-28 22:10:20 +01:00
|
|
|
|
|
|
|
package osfs
|
|
|
|
|
|
|
|
import (
|
2020-04-30 04:02:15 +02:00
|
|
|
"os"
|
|
|
|
|
2019-10-28 22:10:20 +01: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 04:02:15 +02:00
|
|
|
|
|
|
|
func rename(from, to string) error {
|
|
|
|
return os.Rename(from, to)
|
|
|
|
}
|