Add method ListDir
This commit is contained in:
parent
618b0b1639
commit
6f1cc3cc7c
@ -1,9 +1,13 @@
|
||||
package osutils
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func IsDirectory(path string) (bool, error) {
|
||||
@ -39,3 +43,18 @@ func RecursiceWalk(pathToWalk string) ([]string, error) {
|
||||
}
|
||||
return paths, nil
|
||||
}
|
||||
|
||||
func ListDir(path string) ([]fs.FileInfo, error) {
|
||||
files, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return []fs.FileInfo{}, err
|
||||
}
|
||||
return files, nil
|
||||
}
|
||||
|
||||
func GetParentDir(filePath string) (string, error) {
|
||||
cuttedPath := strings.Split(filePath, "/")
|
||||
cuttedPath = cuttedPath[:len(cuttedPath)-1]
|
||||
return path.Join(cuttedPath...), nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user