feat: 实现电脑端被控与控制界面
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
//go:build !windows
|
||||
|
||||
package lockfile
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func lockExclusive(f *os.File) error {
|
||||
err := syscall.Flock(int(f.Fd()), syscall.LOCK_EX|syscall.LOCK_NB)
|
||||
if err == syscall.EWOULDBLOCK || err == syscall.EAGAIN {
|
||||
return ErrBusy
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func unlock(f *os.File) {
|
||||
_ = syscall.Flock(int(f.Fd()), syscall.LOCK_UN)
|
||||
}
|
||||
|
||||
func ownOnly(path string) {
|
||||
_ = os.Chmod(path, 0o600)
|
||||
}
|
||||
Reference in New Issue
Block a user