add isDir func

This commit is contained in:
Jay 2019-02-25 22:25:52 +08:00
parent b266ebeb2d
commit b019626f03
1 changed files with 13 additions and 0 deletions

View File

@ -170,6 +170,19 @@ func CheckExists(filePath string, allowDir bool) bool {
return true
}
// IsDir -
func IsDir(filePath string) bool {
filePath = ParsePath(filePath)
stat, err := os.Stat(filePath)
if err != nil && !os.IsExist(err) {
return false
}
if !stat.IsDir() {
return false
}
return true
}
// SliceIndex -
func SliceIndex(limit int, predicate func(idx int) bool) int {
for i := 0; i < limit; i++ {