ruspa/tree/dir_utils.go

30 lines
413 B
Go
Raw Normal View History

package tree
2020-03-01 23:09:00 +01:00
import (
"os"
)
func ListDir(path string) ([]os.FileInfo, error) {
var files []os.FileInfo
f, err := os.Open(path)
if err != nil {
return files, err
}
defer f.Close()
return f.Readdir(-1)
}
func AnyDirectoryDownThere(path string) bool {
files, err := ListDir(path)
if err != nil {
panic(err)
}
for _, file := range files {
if file.IsDir() {
return true
}
}
return false
}