chore: make webfs usable
This commit is contained in:
@@ -8,12 +8,20 @@ export class Mkdir extends Program {
|
||||
}
|
||||
|
||||
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, workdir: Item, args: string[]): Promise<number> {
|
||||
const item = await Item.openDir(args[1])
|
||||
if (args.length < 2) {
|
||||
stdout.emit("mkdir: error: missing path argument\n")
|
||||
return 1
|
||||
}
|
||||
|
||||
const item = await Item.openDir(args[1].startsWith('/')
|
||||
? args[1]
|
||||
: `${workdir.GetPath()}${workdir.GetPath().endsWith('/') ? '' : '/'}${args[1]}`)
|
||||
|
||||
stdout.emit(`does ${args[1]} exist? ${await item.Exists()}\n`)
|
||||
|
||||
if (await item.Exists()) {
|
||||
stdout.emit(`mkdir: directory ${item.GetPath()} already exists.\n`)
|
||||
return 1
|
||||
return 2
|
||||
}
|
||||
|
||||
item.Create()
|
||||
|
||||
Reference in New Issue
Block a user