2020-02-28 14:44:15 +00:00
|
|
|
package vfscommon
|
|
|
|
|
2020-06-02 18:25:59 +00:00
|
|
|
import (
|
|
|
|
"path"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
2022-01-13 12:33:39 +00:00
|
|
|
// OSFindParent returns the parent directory of name, or "" for the
|
2020-06-02 18:25:59 +00:00
|
|
|
// root for OS native paths.
|
2022-01-13 12:33:39 +00:00
|
|
|
func OSFindParent(name string) string {
|
2020-06-02 18:25:59 +00:00
|
|
|
parent := filepath.Dir(name)
|
2022-01-13 12:33:39 +00:00
|
|
|
if parent == "." || (len(parent) == 1 && parent[0] == filepath.Separator) {
|
2020-06-02 18:25:59 +00:00
|
|
|
parent = ""
|
|
|
|
}
|
|
|
|
return parent
|
|
|
|
}
|
2020-02-28 14:44:15 +00:00
|
|
|
|
|
|
|
// FindParent returns the parent directory of name, or "" for the root
|
2020-06-02 18:25:59 +00:00
|
|
|
// for rclone paths.
|
2020-02-28 14:44:15 +00:00
|
|
|
func FindParent(name string) string {
|
2020-06-02 18:25:59 +00:00
|
|
|
parent := path.Dir(name)
|
2020-02-28 14:44:15 +00:00
|
|
|
if parent == "." || parent == "/" {
|
|
|
|
parent = ""
|
|
|
|
}
|
|
|
|
return parent
|
|
|
|
}
|