Commit dfbf9db0 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Clean up path generation.

parent 6f555712
......@@ -63,13 +63,11 @@ func (me *inodeData) Key() string {
func (me *inodeData) GetPath() (path string, mount *mountData) {
// TODO - softcode this.
var components [100]string
j := len(components)
rev_components := make([]string, 0, 10)
inode := me
for ; inode != nil && inode.mount == nil; inode = inode.Parent {
j--
components[j] = inode.Name
rev_components = append(rev_components, inode.Name)
}
if inode == nil {
panic("did not find parent with mount")
......@@ -81,8 +79,11 @@ func (me *inodeData) GetPath() (path string, mount *mountData) {
if mount.unmountPending {
return "", nil
}
fullPath := strings.Join(components[j:], "/")
components := make([]string, len(rev_components))
for i, v := range rev_components {
components[len(rev_components) - i -1] = v
}
fullPath := strings.Join(components, "/")
return fullPath, mount
}
......
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