|
@@ -348,12 +348,16 @@ func UnderTheSameRoot(srcAbs string, destAbs string) (bool, error) {
|
|
|
return false, nil
|
|
|
}
|
|
|
|
|
|
-//Get the physical root of a given filepath, e.g. C:\ or /home/
|
|
|
+//Get the physical root of a given filepath, e.g. C: or /home
|
|
|
func GetPhysicalRootFromPath(filename string) (string, error) {
|
|
|
filename, err := filepath.Abs(filename)
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
|
+ if filename[:1] == "/" {
|
|
|
+ //Handle cases like /home/pi/foo.txt => return home
|
|
|
+ filename = filename[1:]
|
|
|
+ }
|
|
|
filename = strings.TrimSpace(filename)
|
|
|
if filename == "" {
|
|
|
return "", nil
|