diff --git a/osutils/files.go b/osutils/files.go index fd0a28b..d3e0af7 100644 --- a/osutils/files.go +++ b/osutils/files.go @@ -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 +}