mirror of
https://github.com/apple/container.git
synced 2026-10-16 19:19:15 +00:00
Remove unused, duplicated, and outdated private methods (#667)
Removes unused, duplicated, and outdated private methods.
This commit is contained in:
1 parent
744a7174c6
commit
50560a33cb
1 file changed
-64
@@ -378,70 +378,6 @@ extension EXT4.EXT4Reader {
|
||||
return ResolvedPath(inodeNum: current, inode: finalInode)
|
||||
}
|
||||
|
||||
/// Walk a sequence of path components from a starting inode with parent tracking.
|
||||
/// Returns the final inode and updated parent stack.
|
||||
private func walkWithParents(
|
||||
current start: EXT4.InodeNumber,
|
||||
components: [String],
|
||||
parentStack initialStack: [EXT4.InodeNumber]
|
||||
) throws -> (EXT4.InodeNumber, [EXT4.InodeNumber]) {
|
||||
var current = start
|
||||
var parentStack = initialStack
|
||||
|
||||
if components.isEmpty { return (current, parentStack) }
|
||||
|
||||
for name in components {
|
||||
if name == "." {
|
||||
continue
|
||||
}
|
||||
|
||||
if name == ".." {
|
||||
// Handle parent directory traversal with proper tracking
|
||||
if current == EXT4.RootInode {
|
||||
// At root, ".." points to itself (POSIX behavior)
|
||||
continue
|
||||
}
|
||||
|
||||
// Use parent stack if available for accurate traversal
|
||||
if !parentStack.isEmpty {
|
||||
current = parentStack.removeLast()
|
||||
} else {
|
||||
// No parent tracking available - look up ".." entry in filesystem
|
||||
// This happens when we start traversal from a non-root inode
|
||||
let entries = try children(of: current)
|
||||
if let parent = entries.first(where: { $0.0 == ".." })?.1 {
|
||||
current = parent
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Regular component: verify current is a directory before traversing
|
||||
let currentInode = try getInode(number: current)
|
||||
guard currentInode.mode.isDir() else {
|
||||
throw EXT4.PathIOError.notADirectory(name)
|
||||
}
|
||||
|
||||
// Look up child in current directory
|
||||
let entries = try children(of: current)
|
||||
guard let child = entries.first(where: { $0.0 == name }) else {
|
||||
throw EXT4.PathIOError.notFound(name)
|
||||
}
|
||||
|
||||
// Push current to parent stack before descending
|
||||
parentStack.append(current)
|
||||
current = child.1
|
||||
}
|
||||
|
||||
return (current, parentStack)
|
||||
}
|
||||
|
||||
/// Walk a sequence of path components from a starting inode.
|
||||
private func walk(current start: EXT4.InodeNumber, components: [String]) throws -> EXT4.InodeNumber {
|
||||
let (result, _) = try walkWithParents(current: start, components: components, parentStack: [])
|
||||
return result
|
||||
}
|
||||
|
||||
/// Normalize a path into components, handling absolute and relative paths.
|
||||
private func normalize(path: FilePath) -> [String] {
|
||||
let s = path.description
|
||||
|
||||
Reference in new issue
Block a user