This commit is contained in:
eson 2020-09-18 19:19:56 +08:00
parent 6b4240ac0a
commit a32f5b55f9

View File

@ -36,15 +36,26 @@ type Node struct {
// return string(path) // return string(path)
// } // }
func xPath(spath string) string { func xPath(spath string) {
var path []byte = make([]byte, len(spath)) var path []byte = make([]byte, len(spath)+1)
copy(path, spath) copy(path, spath)
for i := 0; i < len(path); i++ { root := &Node{}
cur := root
for i := 0; i < len(spath); i++ {
c := path[i] c := path[i]
if c == '/' { if c == '/' {
if path[i+1] == '/' {
cur.Type = TypeAllChildren
} else {
cur.Type = TypeChild
}
cur.Next = &Node{Next: cur}
cur = cur.Next
} }
cur.Name = append(cur.Name, c)
} }
} }