2020-02-28 22:44:15 +08:00
|
|
|
package vfscommon
|
|
|
|
|
2020-06-03 02:25:59 +08:00
|
|
|
import (
|
|
|
|
"path"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
// OsFindParent returns the parent directory of name, or "" for the
|
|
|
|
// root for OS native paths.
|
|
|
|
func OsFindParent(name string) string {
|
|
|
|
parent := filepath.Dir(name)
|
|
|
|
if parent == "." || parent == "/" {
|
|
|
|
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
|
|
|
|
}
|