-
Notifications
You must be signed in to change notification settings - Fork 464
/
chezmoi_unix.go
43 lines (33 loc) · 912 Bytes
/
chezmoi_unix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//go:build unix
package chezmoi
import (
"io/fs"
"os"
"golang.org/x/sys/unix"
)
const nativeLineEnding = "\n"
func init() {
Umask = fs.FileMode(unix.Umask(0))
unix.Umask(int(Umask))
}
// findExecutableExtensions returns valid OS executable extensions, on unix it
// can be anything.
func findExecutableExtensions(path string) []string {
return []string{path}
}
// IsExecutable returns if fileInfo is executable.
func IsExecutable(fileInfo fs.FileInfo) bool {
return fileInfo.Mode().Perm()&0o111 != 0
}
// UserHomeDir on UNIX returns the value of os.UserHomeDir.
func UserHomeDir() (string, error) {
return os.UserHomeDir()
}
// isPrivate returns if fileInfo is private.
func isPrivate(fileInfo fs.FileInfo) bool {
return fileInfo.Mode().Perm()&0o77 == 0
}
// isReadOnly returns if fileInfo is read-only.
func isReadOnly(fileInfo fs.FileInfo) bool {
return fileInfo.Mode().Perm()&0o222 == 0
}