1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-17 03:02:28 +08:00

feat: add CreateDir function in file.go

This commit is contained in:
dudaodong
2022-06-08 14:38:35 +08:00
parent 9aa3b742ff
commit 2c0ab9e922
2 changed files with 27 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ import (
"io/ioutil"
"net/http"
"os"
"path"
"path/filepath"
"strings"
)
@@ -40,6 +41,11 @@ func CreateFile(path string) bool {
return true
}
// CreateDir create directory in absolute path. param `absPath` like /a/, /a/b/
func CreateDir(absPath string) error {
return os.MkdirAll(path.Dir(absPath), os.ModePerm)
}
// IsDir checks if the path is directory or not
func IsDir(path string) bool {
file, err := os.Stat(path)