- cat added

- touch beginnings
- path resolver now returns a -1 on error
- added a command template file for easier copy-pasting
This commit is contained in:
2026-09-01 05:47:23 +02:00
parent 8e054a220d
commit 2e9227f6d8
7 changed files with 169 additions and 25 deletions
+5 -10
View File
@@ -16,16 +16,11 @@ export function resolvePath(state: ShellState, path: string): number {
let currentNode = isAbsolute
? state.filesystem.getRoot()
: (state.filesystem.getNode(session.cwd) as DirectoryNode);
if (!currentNode) {
throw {
type: "NodeNotFound",
message: `CWD node under inode ${session.cwd} not found`,
timestamp: Date.now(),
inode: session.cwd,
} satisfies NodeNotFoundError;
}
for (const name of pathComponents) {
if (!currentNode) return -1;
for (let i = 0; i < pathComponents.length; i++) {
const name = pathComponents[i]!;
if (name === ".") continue;
if (name === "..") {
@@ -42,7 +37,7 @@ export function resolvePath(state: ShellState, path: string): number {
timestamp: Date.now(),
inode: currentNode.inode,
} satisfies NodeNotFoundError;
if (state.filesystem.isFile(inode))
if (state.filesystem.isFile(inode) && !(i === pathComponents.length - 1))
throw {
type: "NotADirectory",
message: `Child node ${name} is not a directory`,