-
Notifications
You must be signed in to change notification settings - Fork 0
/
sys_windows.go
39 lines (32 loc) · 930 Bytes
/
sys_windows.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
package xsum
import (
"errors"
"os"
"syscall"
"github.com/sclevine/xsum/encoding"
)
func getSys(fi os.FileInfo) (*Sys, error) {
if stat, ok := fi.Sys().(*syscall.Win32FileAttributeData); ok && stat != nil {
return &Sys{
Mtime: filetimeToTimespec(stat.LastWriteTime),
Ctime: filetimeToTimespec(stat.CreationTime),
}, nil
}
return nil, ErrNoStat
}
func getXattr(_ string, _ Hash, _ bool) ([]encoding.NamedHash, error) {
return nil, ErrNoXattr
}
func filetimeToTimespec(ft syscall.Filetime) *encoding.Timespec {
ts := encoding.Timespec(syscall.NsecToTimespec(ft.Nanoseconds()))
return &ts
}
func validateMask(mask Mask) error {
if mask.Mode&(sModeSetuid|sModeSetgid|sModeSticky|0111) != 0 {
return errors.New("masks >0666 unsupported on Windows")
}
if mask.Attr&(AttrUID|AttrGID|AttrX|AttrSpecial) != 0 {
return errors.New("masks with UID/GID/xattr/special unsupported on Windows")
}
return nil
}