Commit 7d4c2306 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Implement PathFs.LastNode() using FileSystemConnector.Node().

parent 04f7c3eb
......@@ -189,8 +189,9 @@ func (me *FileSystemConnector) Node(parent *Inode, fullPath string) (*Inode, []s
return parent, nil
}
fullPath = strings.TrimLeft(filepath.Clean(fullPath), "/")
comps := strings.Split(fullPath, "/")
sep := string(filepath.Separator)
fullPath = strings.TrimLeft(filepath.Clean(fullPath), sep)
comps := strings.Split(fullPath, sep)
node := parent
if node.mountPoint == nil {
......
......@@ -5,7 +5,6 @@ import (
"log"
"os"
"path/filepath"
"strings"
"sync"
)
......@@ -123,22 +122,7 @@ func (me *PathNodeFs) Path(node *Inode) string {
}
func (me *PathNodeFs) LastNode(name string) (*Inode, []string) {
if name == "" {
return me.Root().Inode(), nil
}
name = filepath.Clean(name)
comps := strings.Split(name, string(filepath.Separator))
node := me.root.Inode()
for i, c := range comps {
next := node.GetChild(c)
if next == nil {
return node, comps[i:]
}
node = next
}
return node, nil
return me.connector.Node(me.Root().Inode(), name)
}
func (me *PathNodeFs) FileNotify(path string, off int64, length int64) Status {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment