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