feat: working filesystem

This commit is contained in:
binekrasik
2026-05-15 14:16:11 +02:00
parent 97b9994594
commit 4c67f2aee3
15 changed files with 449 additions and 95 deletions

View File

@@ -0,0 +1,35 @@
import { Item } from '../fs/Item'
import type { SimpleStream } from '../utils/SimpleStream'
import { Program } from './Program'
export class Rm extends Program {
constructor() {
super()
}
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, workdir: Item, args: string[]): Promise<number> {
if (!args[1]) {
stdout.emit("rm: error: missing first argument\n")
return 1
}
let item: Item
try {
item = await Item.openDir(args[1])
} catch {
item = await Item.open(args[1])
}
if (!(await item.Exists())) {
stdout.emit(`rm: error: item ${item.GetPath()} doesn't exist.\n`)
return 1
}
stdout.emit(`removing: '${item.GetPath()}'\n`)
await item.Delete()
return 0
}
}