From b019626f034958e12510800da7bc584e143f38a9 Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 25 Feb 2019 22:25:52 +0800 Subject: [PATCH] add isDir func --- utils.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/utils.go b/utils.go index 0d5ef38..79b53c6 100644 --- a/utils.go +++ b/utils.go @@ -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++ {