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