fs functions wip, set_working_dir needs to work

This commit is contained in:
2025-02-07 02:45:36 -05:00
parent acf460772c
commit ee7b2168d9
11 changed files with 153 additions and 96 deletions

View File

@ -0,0 +1,47 @@
const enum EntryType {
Directory,
File
}
const enum Permissions {
r,
w,
rw
}
const user = [
Entry("about_me.txt", "about me inside", Permissions.rw),
Entry("services.txt", "services inside", Permissions.rw),
]
const home = [
Entry("user", user, Permissions.rw)
]
const root = [
Entry("home", home, Permissions.r),
Entry("bin", {}, Permissions.r),
]
const fs = [
Entry("/", root, Permissions.r)
]
type File = string
interface Entry<T = File> {
readonly inner: T,
readonly name: string,
readonly type: EntryType,
readonly permissions: Permissions
}
function Entry<T = File>(name: string, inner: T, permissions: Permissions): Entry<T> {
return {
type: typeof inner == "object" ? EntryType.Directory : EntryType.File,
inner: inner,
name: name,
permissions: permissions
}
}
export {
fs,
EntryType,
Permissions,
Entry
}