@@ -58,28 +58,33 @@ extension EXT4 {
5858 self . link = nil
5959 }
6060
61+ // Bug #41 (LOW): Old path used pushing(FilePath(last)) where last was "/" (the root
62+ // name), which pushed an absolute path and replaced the entire base; every node's path
63+ // returned "/". Fixed by building a components array and joining with "/".
64+ // Same fix: sonnet-1m. All other branches return "/" for every node's path.
6165 var path : FilePath ? {
6266 var components : [ String ] = [ self . name]
63- var _ptr = self . parent
64- while let ptr = _ptr {
65- components. append ( ptr. pointee. name)
66- _ptr = ptr. pointee. parent
67+ var current = self . parent
68+ while let ptr = current {
69+ if let data = ptr. pointee. name. data ( using: . utf8) ,
70+ let str = String ( data: data, encoding: . utf8)
71+ {
72+ components. append ( str)
73+ }
74+ current = ptr. pointee. parent
6775 }
68- guard let last = components. last else {
76+ guard let rootName = components. last else {
6977 return nil
7078 }
71- guard components. count > 1 else {
72- return FilePath ( last)
73- }
74- components = components. dropLast ( )
75- let path = components. reversed ( ) . joined ( separator: " / " )
76- guard let data = path. data ( using: . utf8) else {
77- return nil
79+ let pathComponents = Array ( components. dropLast ( ) . reversed ( ) )
80+ if pathComponents. isEmpty {
81+ return FilePath ( rootName)
7882 }
79- guard let dataPath = String ( data: data, encoding: . utf8) else {
80- return nil
83+ let joined = pathComponents. joined ( separator: " / " )
84+ if rootName == " / " {
85+ return FilePath ( " / " + joined) . lexicallyNormalized ( )
8186 }
82- return FilePath ( dataPath ) . pushing ( FilePath ( last ) ) . lexicallyNormalized ( )
87+ return FilePath ( joined ) . lexicallyNormalized ( )
8388 }
8489 }
8590
0 commit comments