1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-20 05:22:21 +08:00
Files
kubo/commands/files/is_hidden_windows.go
gatesvp e55a130b49 Add hidden file support to add
License: MIT
Signed-off-by: Gaetan Voyer-Perrault <gatesvp@gmail.com>
2015-07-09 04:07:34 -07:00

30 lines
436 B
Go

// +build windows
package files
import (
"path/filepath"
"strings"
"syscall"
)
func IsHidden(f File) bool {
fName := filepath.Base(f.FileName())
if strings.HasPrefix(fName, ".") && len(fName) > 1 {
return true
}
p, e := syscall.UTF16PtrFromString(f.FileName())
if e != nil {
return false
}
attrs, e := syscall.GetFileAttributes(p)
if e != nil {
return false
}
return attrs&syscall.FILE_ATTRIBUTE_HIDDEN != 0
}