mirror of
https://github.com/charmbracelet/gum
synced 2024-06-16 12:35:06 +02:00
21 lines
399 B
Go
21 lines
399 B
Go
|
//go:build windows
|
||
|
|
||
|
package file
|
||
|
|
||
|
import (
|
||
|
"syscall"
|
||
|
)
|
||
|
|
||
|
// IsHidden reports whether a file is hidden or not.
|
||
|
func IsHidden(file string) (bool, error) {
|
||
|
pointer, err := syscall.UTF16PtrFromString(file)
|
||
|
if err != nil {
|
||
|
return false, err
|
||
|
}
|
||
|
attributes, err := syscall.GetFileAttributes(pointer)
|
||
|
if err != nil {
|
||
|
return false, err
|
||
|
}
|
||
|
return attributes&syscall.FILE_ATTRIBUTE_HIDDEN != 0, nil
|
||
|
}
|