Fix: unhandled errors (#1419)

As these errors where not explicitly ignored with _, I made changes to make sure they bubble up.
This commit is contained in:
EnameEtavir
2021-05-25 10:40:51 +02:00
committed by GitHub
parent 65baf46c40
commit d6ada23616
8 changed files with 37 additions and 9 deletions

View File

@@ -106,21 +106,23 @@ func EmptyDir(path string) error {
}
// ListDir will return the contents of a given directory path as a string slice
func ListDir(path string) []string {
func ListDir(path string) ([]string, error) {
var dirPaths []string
files, err := ioutil.ReadDir(path)
if err != nil {
path = filepath.Dir(path)
files, err = ioutil.ReadDir(path)
if err != nil {
return dirPaths, err
}
}
var dirPaths []string
for _, file := range files {
if !file.IsDir() {
continue
}
dirPaths = append(dirPaths, filepath.Join(path, file.Name()))
}
return dirPaths
return dirPaths, nil
}
// GetHomeDirectory returns the path of the user's home directory. ~ on Unix and C:\Users\UserName on Windows