OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / vendor / github.com / ipfs / go-ipfs-files / is_hidden_windows.go
1 // +build windows
2
3 package files
4
5 import (
6         "path/filepath"
7         "strings"
8
9         windows "golang.org/x/sys/windows"
10 )
11
12 func IsHidden(name string, f Node) bool {
13
14         fName := filepath.Base(name)
15
16         if strings.HasPrefix(fName, ".") && len(fName) > 1 {
17                 return true
18         }
19
20         fi, ok := f.(FileInfo)
21         if !ok {
22                 return false
23         }
24
25         p, e := windows.UTF16PtrFromString(fi.AbsPath())
26         if e != nil {
27                 return false
28         }
29
30         attrs, e := windows.GetFileAttributes(p)
31         if e != nil {
32                 return false
33         }
34         return attrs&windows.FILE_ATTRIBUTE_HIDDEN != 0
35 }