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

27
src/program/Echo.ts Normal file
View File

@@ -0,0 +1,27 @@
import { Item } from '../fs/Item'
import type { SimpleStream } from '../utils/SimpleStream'
import { Program } from './Program'
export class Echo extends Program {
constructor() {
super()
}
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, ___: Item, args: string[]): Promise<number> {
let item: Item = await Item.open(args[1])
if (!(await item.Exists())) {
stdout.emit(`echo: error: item ${item.GetPath()} doesn't exist.\n`)
return 1
}
if (item.IsDirectory()) {
stdout.emit(`echo: error: can't write data to a directory; item ${item.GetPath()} is a directory.\n`)
return 2
}
await item.Write(args.slice(2).join(' '))
return 0
}
}