WIP: No idea what exactly i did over those past 2 days

This commit is contained in:
2026-05-11 19:06:06 +02:00
parent f50fc96416
commit 106abd851a
27 changed files with 605 additions and 59 deletions
+54 -19
View File
@@ -1,6 +1,5 @@
import type { Bash } from "./bash";
import type { User } from "./etc/userData";
import type { Permission, TimeStamps } from "./metadata";
import type { User } from './etc/userData';
import type { Permission, TimeStamps } from './metadata';
export enum Type {
Directory = 16384,
@@ -8,7 +7,7 @@ export enum Type {
SymbolicLink = 40960
}
export type NodePerms = {
export type NodePermission = {
user: Permission;
group: Permission;
other: Permission;
@@ -65,8 +64,7 @@ export class VirtualFS {
if (!currentNode)
throw new Error('could not find the node in the fs table - inodetopathstring');
if (!currentNode.parent ||
currentNode.inode === this.rootINode) {
if (!currentNode.parent || currentNode.inode === this.rootINode) {
return '/';
}
@@ -157,26 +155,63 @@ export class VirtualFS {
return node;
}
public recursiveTraversalPre(node: TreeNode, callback: (param: TreeNode) => void, childIndex?: number[], depthIndex?: number): void {
if(!depthIndex) depthIndex = 0;
if(!childIndex) childIndex = [0];
public recursiveTraversalPre(
node: TreeNode,
callback: (param: TreeNode) => void,
childIndex?: number[],
depthIndex?: number
): void {
if (!depthIndex) depthIndex = 0;
if (!childIndex) childIndex = [0];
if(node.type != Type.File && node.children[childIndex[depthIndex]]) {
if (node.type != Type.File && node.children[childIndex[depthIndex]]) {
node = this.getNodeByINode(node.children[childIndex[depthIndex]]);
depthIndex++;
if(!childIndex[depthIndex]) childIndex[depthIndex] = 0;
depthIndex++;
if (!childIndex[depthIndex]) childIndex[depthIndex] = 0;
callback(node);
}
else {
} else {
node = this.getNodeByINode(node.parent);
childIndex[depthIndex] = 0;
depthIndex--;
childIndex[depthIndex]++;
childIndex[depthIndex] = 0;
depthIndex--;
childIndex[depthIndex]++;
}
if(depthIndex < 0) return;
if (depthIndex < 0) return;
this.recursiveTraversalPre(node, callback, childIndex, depthIndex);
}
private _createNode(name: string, type: Type, path: number, user: number): void {
let children: null | number[];
const node: TreeNode = {
inode: this.FsTable.size + 1,
name: name,
type: type,
size: 4096, //TODO: Calculate the size from the content
children: [],
content: '',
link: -1,
permission: {
user: {
r: true,
w: true,
x: false
},
group: {
r: true,
w: false,
x: false
},
other: {
r: true,
w: false,
x: false
}
},
owner: user,
group:
}
}
}