Commit a9a052ec authored by gatesvp's avatar gatesvp Committed by Juan Batiz-Benet

Add hidden file support to add

License: MIT
Signed-off-by: default avatarGaetan Voyer-Perrault <gatesvp@gmail.com>
parent 7b3973db
// +build !windows
package files
import (
"path/filepath"
"strings"
)
func IsHidden(f File) bool {
fName := filepath.Base(f.FileName())
if strings.HasPrefix(fName, ".") && len(fName) > 1 {
return true
}
return false
}
// +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
}
......@@ -3,7 +3,7 @@ package files
import (
"io"
"os"
fp "path"
fp "path/filepath"
"sort"
"syscall"
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment