-
-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathutils_windows.go
More file actions
43 lines (38 loc) · 942 Bytes
/
Copy pathutils_windows.go
File metadata and controls
43 lines (38 loc) · 942 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
40
41
42
43
package doublestar
import (
"io/fs"
"syscall"
)
// Returns true if the pattern could "unintentionally" match hidden files/dirs.
// An unintentional pattern would use a meta character that could match
// anything.
func couldUnintentionallyMatchHidden(pattern string) bool {
var c byte
inClass := false
l := len(pattern)
for i := 0; i < l; i++ {
c = pattern[i]
if !inClass && (c == '*' || c == '?') {
return true
} else if c == '[' {
inClass = true
} else if c == '\\' {
// skip next byte
i++
} else if inClass && c == ']' {
inClass = false
}
}
return false
}
// Returns true if the file is "hidden"
func isHiddenPath(_filename string, info fs.DirEntry) (bool, error) {
fileinfo, err := info.Info()
if err != nil {
return false, err
}
if stat, ok := fileinfo.Sys().(*syscall.Win32FileAttributeData); ok {
return stat.FileAttributes&syscall.FILE_ATTRIBUTE_HIDDEN != 0, nil
}
return false, nil
}