is_hidden_windows.go 436 Bytes
Newer Older
gatesvp's avatar
gatesvp committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// +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
	}

Jeromy's avatar
Jeromy committed
19
	p, e := syscall.UTF16PtrFromString(f.FullPath())
gatesvp's avatar
gatesvp committed
20 21 22 23 24 25 26 27 28 29
	if e != nil {
		return false
	}

	attrs, e := syscall.GetFileAttributes(p)
	if e != nil {
		return false
	}
	return attrs&syscall.FILE_ATTRIBUTE_HIDDEN != 0
}