mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Overhaul look and feel of folder select (#527)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user