add isDir func

This commit is contained in:
Jay 2019-02-25 22:25:52 +08:00
parent b266ebeb2d
commit b019626f03

View File

@ -170,6 +170,19 @@ func CheckExists(filePath string, allowDir bool) bool {
return true 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 - // SliceIndex -
func SliceIndex(limit int, predicate func(idx int) bool) int { func SliceIndex(limit int, predicate func(idx int) bool) int {
for i := 0; i < limit; i++ { for i := 0; i < limit; i++ {