Files
sqlite3/vfs/os_unix.go

34 lines
584 B
Go
Raw Normal View History

2023-10-17 14:04:23 +01:00
//go:build unix && !sqlite3_nosys
2023-01-26 14:52:38 +00:00
2023-06-01 18:11:37 +01:00
package vfs
2023-01-25 14:59:02 +00:00
2023-01-25 16:23:18 +00:00
import (
"os"
2023-06-02 02:31:15 +01:00
"syscall"
2023-03-09 01:59:46 +00:00
"golang.org/x/sys/unix"
2023-01-25 16:23:18 +00:00
)
2023-01-25 14:59:02 +00:00
2023-05-19 03:04:07 +01:00
func osAccess(path string, flags AccessFlag) error {
2023-03-23 13:28:25 +00:00
var access uint32 // unix.F_OK
2023-03-09 01:59:46 +00:00
switch flags {
2023-05-19 03:04:07 +01:00
case ACCESS_READWRITE:
2023-03-09 01:59:46 +00:00
access = unix.R_OK | unix.W_OK
2023-05-19 03:04:07 +01:00
case ACCESS_READ:
2023-03-09 01:59:46 +00:00
access = unix.R_OK
}
2023-03-17 17:13:03 +00:00
return unix.Access(path, access)
2023-03-10 14:02:34 +00:00
}
2023-06-02 02:31:15 +01:00
func osSetMode(file *os.File, modeof string) error {
fi, err := os.Stat(modeof)
if err != nil {
return err
}
file.Chmod(fi.Mode())
if sys, ok := fi.Sys().(*syscall.Stat_t); ok {
file.Chown(int(sys.Uid), int(sys.Gid))
}
return nil
}