- Fixed ls (mostly)

- Fixed sorting
- Many minor changes

(need to fix the json serializer to include size in its results *the C++ one*)
This commit is contained in:
2026-11-10 16:19:10 +01:00
parent 492f1ba372
commit b161e42b3f
7 changed files with 179 additions and 226 deletions
+5 -3
View File
@@ -8,7 +8,7 @@ export function deserializeFileSystem(json: string): { id: number; map: Map<numb
const raw = JSON.parse(json);
// prettier-ignore
function parseNode(tree: any, map: Map<number, Node>): void { // eslint-disable-line @typescript-eslint/no-explicit-any
function parseNode(tree: any, parent: number, map: Map<number, Node>): void { // eslint-disable-line @typescript-eslint/no-explicit-any
if(tree === null || tree.type === undefined) {
const time = Date.now();
const defaultNode: DirectoryNode = {
@@ -32,7 +32,7 @@ export function deserializeFileSystem(json: string): { id: number; map: Map<numb
const children: Map<string, number> = new Map();
for (const child of tree.children) {
parseNode(child, map);
parseNode(child, tree.inode, map);
children.set(child.name, child.inode);
}
@@ -48,6 +48,8 @@ export function deserializeFileSystem(json: string): { id: number; map: Map<numb
atime: tree.atime,
children,
};
children.set('..', parent);
children.set('.', tree.inode);
map.set(tree.inode, Object.freeze(directoryNode));
break;
}
@@ -92,7 +94,7 @@ export function deserializeFileSystem(json: string): { id: number; map: Map<numb
const result: { id: number; map: Map<number, Node> }[] = [];
for (const dev of raw.dev) {
const map = new Map();
parseNode(dev.tree, map);
parseNode(dev.tree, dev.tree.inode, map);
result.push({ id: dev.id, map });
}