vfs: fix OS vs Unix path confusion - fixes ChangeNotify on Windows

See: https://forum.rclone.org/t/windows-mount-polling-not-recognising-all-changes-made-by-another-box/16708
This commit is contained in:
Nick Craig-Wood
2020-06-02 19:25:59 +01:00
parent 151f03378f
commit 50e31c6636
2 changed files with 25 additions and 6 deletions

View File

@@ -1,12 +1,26 @@
package vfscommon
import "path/filepath"
import (
"path"
"path/filepath"
)
// FindParent returns the parent directory of name, or "" for the root
func FindParent(name string) string {
// 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
}
// FindParent returns the parent directory of name, or "" for the root
// for rclone paths.
func FindParent(name string) string {
parent := path.Dir(name)
if parent == "." || parent == "/" {
parent = ""
}
return parent
}