-
-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathutils_windows_test.go
More file actions
39 lines (32 loc) · 808 Bytes
/
Copy pathutils_windows_test.go
File metadata and controls
39 lines (32 loc) · 808 Bytes
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 doublestar
import (
"log"
"syscall"
)
func mkdirpHidden(parts ...string) string {
dir := mkdirp(parts...)
return makeHidden(dir)
}
func touchHidden(parts ...string) string {
file := touch(parts...)
return makeHidden(file)
}
func makeHidden(path string) string {
pointer, err := syscall.UTF16PtrFromString(path)
if err != nil {
log.Fatalf("Could not make %v hidden: %v\n", path, err)
return path
}
attributes, err := syscall.GetFileAttributes(pointer)
if err != nil {
log.Fatalf("Could not make %v hidden: %v\n", path, err)
return path
}
if attributes&syscall.FILE_ATTRIBUTE_HIDDEN == 0 {
err = syscall.SetFileAttributes(pointer, attributes|syscall.FILE_ATTRIBUTE_HIDDEN)
if err != nil {
log.Fatalf("Could not make %v hidden: %v\n", path, err)
}
}
return path
}