Overhaul look and feel of folder select (#527)

This commit is contained in:
InfiniteTF
2020-05-09 05:08:00 +02:00
committed by GitHub
parent e9c68897d7
commit 328db57d6c
8 changed files with 111 additions and 24 deletions

View File

@@ -96,15 +96,6 @@ func EmptyDir(path string) error {
// ListDir will return the contents of a given directory path as a string slice
func ListDir(path string) []string {
if path == "" {
path = GetHomeDirectory()
}
absolutePath, err := filepath.Abs(path)
if err == nil {
path = absolutePath
}
files, err := ioutil.ReadDir(path)
if err != nil {
path = filepath.Dir(path)
@@ -133,3 +124,25 @@ func GetHomeDirectory() string {
}
return currentUser.HomeDir
}
func GetDir(path string) string {
if path == "" {
path = GetHomeDirectory()
}
absolutePath, err := filepath.Abs(path)
if err == nil {
path = absolutePath
}
return absolutePath
}
func GetParent(path string) *string {
isRoot := path[len(path)-1:] == "/"
if isRoot {
return nil
} else {
parentPath := filepath.Clean(path + "/..")
return &parentPath
}
}