- Downward tree traversal fixed (untested - might have bugs)

- Moved filesystem mockups to a separate file
- Tree visualizer now has support for symlinks and mountpoints
This commit is contained in:
2026-11-10 09:08:15 +01:00
parent 4fa284de13
commit 584e594726
4 changed files with 252 additions and 243 deletions
+11 -9
View File
@@ -1,26 +1,28 @@
import type { FileSystem } from "@core/filesystem/filesystem";
import { fromPtr, NodeType, toPtr, type NodeEntry, type NodePointer } from "@core/filesystem/node";
export function dnTraverseTree(fs: FileSystem, root: number): number[] {
export function dnTraverseTree(fs: FileSystem, root: NodePointer): NodePointer[] {
if (fs.getNode(root) === undefined) return [];
const result: number[] = [];
const stack: number[] = [];
const result: NodePointer[] = [];
const stack: NodePointer[] = [];
stack.push(root);
while (stack.length > 0) {
const node = fs.getNode(stack.pop() as number);
if (node === undefined) continue;
const ptr = stack.pop()!;
const node = fs.getNode(ptr);
if (!node) continue;
result.push(node.inode);
result.push(ptr);
if (node.type === NodeType.Directory) {
const children = Object.values(node.children);
const children = Array.from(node.children.values());
for (let i = children.length - 1; i >= 0; i--) {
stack.push(children[i] as number);
const child = children[i]!;
const pointer = toPtr({ device_id: Number(ptr.split(":")[0]), inode: child });
stack.push(pointer);
}
}
}
return result;
}