-
Notifications
You must be signed in to change notification settings - Fork 11
/
extractor_unix.go
46 lines (36 loc) · 865 Bytes
/
extractor_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
44
45
46
// +build !windows
package fastzip
import (
"os"
"runtime"
"time"
"golang.org/x/sys/unix"
)
func lchmod(name string, mode os.FileMode) error {
var flags int
if runtime.GOOS == "linux" {
if mode&os.ModeSymlink != 0 {
return nil
}
} else {
flags = unix.AT_SYMLINK_NOFOLLOW
}
err := unix.Fchmodat(unix.AT_FDCWD, name, uint32(mode), flags)
if err != nil {
return &os.PathError{Op: "lchmod", Path: name, Err: err}
}
return nil
}
func lchtimes(name string, mode os.FileMode, atime, mtime time.Time) error {
at := unix.NsecToTimeval(atime.UnixNano())
mt := unix.NsecToTimeval(mtime.UnixNano())
tv := [2]unix.Timeval{at, mt}
err := unix.Lutimes(name, tv[:])
if err != nil {
return &os.PathError{Op: "lchtimes", Path: name, Err: err}
}
return nil
}
func lchown(name string, uid, gid int) error {
return os.Lchown(name, uid, gid)
}