mirror of https://github.com/cheat/cheat.git
28 lines
392 B
Go
28 lines
392 B
Go
// +build !plan9,!windows,!js
|
|
|
|
package osfs
|
|
|
|
import (
|
|
"os"
|
|
|
|
"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)
|
|
}
|
|
|
|
func rename(from, to string) error {
|
|
return os.Rename(from, to)
|
|
}
|