2022-03-01 10:51:15 -05:00
|
|
|
//go:build !windows
|
2018-06-08 12:23:38 -04:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package fs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2022-03-01 10:51:15 -05:00
|
|
|
"runtime"
|
2018-06-08 12:23:38 -04:00
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
2022-03-01 10:51:15 -05:00
|
|
|
const defaultRootDirMode = os.ModeDir | 0700
|
|
|
|
|
|
|
|
var defaultSymlinkMode = os.ModeSymlink | 0777
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
switch runtime.GOOS {
|
|
|
|
case "darwin":
|
|
|
|
defaultSymlinkMode = os.ModeSymlink | 0755
|
|
|
|
}
|
|
|
|
}
|
2018-06-08 12:23:38 -04:00
|
|
|
|
|
|
|
func newResourceFromInfo(info os.FileInfo) resource {
|
|
|
|
statT := info.Sys().(*syscall.Stat_t)
|
|
|
|
return resource{
|
|
|
|
mode: info.Mode(),
|
|
|
|
uid: statT.Uid,
|
|
|
|
gid: statT.Gid,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *filePath) SetMode(mode os.FileMode) {
|
|
|
|
p.file.mode = mode
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *directoryPath) SetMode(mode os.FileMode) {
|
|
|
|
p.directory.mode = mode | os.ModeDir
|
|
|
|
}
|