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