Bring the Wails desktop shell to feature parity with the CLI for provider and alias management while keeping the browser fallback working. Wire tray, notifications, autostart, and GUI warnings so desktop flows behave predictably.
36 lines
646 B
Go
36 lines
646 B
Go
//go:build !windows
|
|
|
|
package fileutil
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
func lockFile(file *os.File) error {
|
|
if err := syscall.Flock(int(file.Fd()), syscall.LOCK_EX); err != nil {
|
|
return fmt.Errorf("flock lock: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func unlockFile(file *os.File) error {
|
|
if err := syscall.Flock(int(file.Fd()), syscall.LOCK_UN); err != nil {
|
|
return fmt.Errorf("flock unlock: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func syncDir(dir string) error {
|
|
f, err := os.Open(dir)
|
|
if err != nil {
|
|
return fmt.Errorf("open dir: %w", err)
|
|
}
|
|
defer f.Close()
|
|
if err := f.Sync(); err != nil {
|
|
return fmt.Errorf("sync dir: %w", err)
|
|
}
|
|
return nil
|
|
}
|