Module fs
File handles (WHATWG File System, WICG File System Access; src/page/fs_store.odin, fs_api.odin; native/js/runtime/web_fs.c). A handle is a root (the origin private file system of the realm's storage key, or a folder of the user's disk given by a picker or a drop) and a "/"-joined path of names below it ("" is the root). Errors carry their DOMException's name first in the message ("TypeMismatchError: ...").
Exposed to: Window, Worker. Source: api/fs.widl.
Odin: import "wren:fs".
Functions
Fs_opfsRoot
u64 Fs_opfsRoot(usvstring bucket) raisesnavigator.storage.getDirectory(): the root of the realm's origin private file system. Security outside a secure
context, for an opaque origin or a profile without a folder. bucket: a storage bucket's (StorageBucket.getDirectory),
"" for the default one; Invalid_State once the bucket was deleted.
Odin: fs.opfsRoot.
Raises: returns an Error (see web).
Host: Fs_opfsRoot :: proc(c: ^Call, bucket: string) -> (u64, Api_Error)
Fs_getEntry
string Fs_getEntry(u64 root, string path, string name, bool directory, bool create) raisesgetFileHandle / getDirectoryHandle(name, {create}) on the directory at path: the child's path. Not_Found,
Type (an invalid name), Not_Allowed (no permission), Invalid_State ("TypeMismatchError": the other kind).
Odin: fs.getEntry.
Raises: returns an Error (see web).
Host: Fs_getEntry :: proc(c: ^Call, root: u64, path: string, name: string, directory: bool, create: bool) -> (string, Api_Error)
Fs_removeEntry
void Fs_removeEntry(u64 root, string path, string name, bool recursive) raisesremoveEntry(name, {recursive}): Invalid_Modification for a directory that is not empty, No_Modification_Allowed for an entry in use.
Odin: fs.removeEntry.
Raises: returns an Error (see web).
Host: Fs_removeEntry :: proc(c: ^Call, root: u64, path: string, name: string, recursive: bool) -> Api_Error
Fs_list
string Fs_list(u64 root, string path) raisesThe directory's entries: "f" or "d", a tab, the name, one per line.
Odin: fs.list.
Raises: returns an Error (see web).
Host: Fs_list :: proc(c: ^Call, root: u64, path: string) -> (string, Api_Error)
Fs_resolve
string Fs_resolve(u64 root, string path, u64 root2, string path2) raisesresolve(): the names from the first entry down to the second, "/"-joined (Not_Found: not below it).
Odin: fs.resolve.
Raises: returns an Error (see web).
Host: Fs_resolve :: proc(c: ^Call, root: u64, path: string, root2: u64, path2: string) -> (string, Api_Error)
Fs_same
bool Fs_same(u64 root, string path, u64 root2, string path2)isSameEntry
Odin: fs.same.
Host: Fs_same :: proc(c: ^Call, root: u64, path: string, root2: u64, path2: string) -> bool
Fs_getFile
u64 Fs_getFile(u64 root, string path) raisesgetFile(): a File object (a LocalFile of module dnd: read on demand).
Odin: fs.getFile.
Raises: returns an Error (see web).
Host: Fs_getFile :: proc(c: ^Call, root: u64, path: string) -> (u64, Api_Error)
Fs_open
u64 Fs_open(u64 root, string path, bool keep, bool sync) raisescreateWritable({keepExistingData}) (a temporary file) or createSyncAccessHandle() (sync: the file itself,
exclusive): an open entry's id. No_Modification_Allowed while it is locked.
Odin: fs.open.
Raises: returns an Error (see web).
Host: Fs_open :: proc(c: ^Call, root: u64, path: string, keep: bool, sync: bool) -> (u64, Api_Error)
Fs_write
i64 Fs_write(u64 id, i64 at, bytes data) raisesWrites at at (-1: the cursor): the bytes written. Quota past opfs.max_bytes_per_origin.
Odin: fs.write.
Raises: returns an Error (see web).
Host: Fs_write :: proc(c: ^Call, id: u64, at: i64, data: []u8) -> (i64, Api_Error)
Fs_read
i64 Fs_read(u64 id, i64 at, out bytes into) raisesReads into into from at (-1: the cursor): the bytes read.
Odin: fs.read.
Raises: returns an Error (see web).
Host: Fs_read :: proc(c: ^Call, id: u64, at: i64, into: []u8) -> (i64, Api_Error)
Fs_seek
void Fs_seek(u64 id, i64 position) raisesOdin: fs.seek.
Raises: returns an Error (see web).
Host: Fs_seek :: proc(c: ^Call, id: u64, position: i64) -> Api_Error
Fs_truncate
void Fs_truncate(u64 id, i64 size) raisesOdin: fs.truncate.
Raises: returns an Error (see web).
Host: Fs_truncate :: proc(c: ^Call, id: u64, size: i64) -> Api_Error
Fs_size
i64 Fs_size(u64 id) raisesOdin: fs.size.
Raises: returns an Error (see web).
Host: Fs_size :: proc(c: ^Call, id: u64) -> (i64, Api_Error)
Fs_flush
void Fs_flush(u64 id) raisesOdin: fs.flush.
Raises: returns an Error (see web).
Host: Fs_flush :: proc(c: ^Call, id: u64) -> Api_Error
Fs_close
void Fs_close(u64 id, bool commit) raisesclose(): a writable's temporary file replaces the entry (commit false: abort); a sync handle's lock goes.
Odin: fs.close.
Raises: returns an Error (see web).
Host: Fs_close :: proc(c: ^Call, id: u64, commit: bool) -> Api_Error
Fs_permission
i32 Fs_permission(u64 root, bool write)queryPermission: 0 granted, 1 prompt, 2 denied.
Odin: fs.permission.
Host: Fs_permission :: proc(c: ^Call, root: u64, write: bool) -> i32
Fs_requestPermission
Promise Fs_requestPermission(u64 root, bool write) raisesrequestPermission({mode}): a promise of the state after (the user may be asked).
Odin: fs.requestPermission.
Raises: returns an Error (see web).
Host: Fs_requestPermission :: proc(c: ^Call, root: u64, write: bool) -> (u64, Api_Error)
Fs_showPicker
Promise Fs_showPicker(i32 kind, string types, bool multiple, bool exclude_all, string suggested, string start_in, u64 start_root, string start_path, string id, bool readwrite) raisesshowOpenFilePicker (kind 0), showSaveFilePicker (1), showDirectoryPicker (2): a promise of the number of
handles, its text one line per handle: root TAB path TAB "f" or "d" TAB name. Abort when cancelled, Security
without a user gesture, Not_Supported when disabled. types: a line per type, description TAB patterns...
Odin: fs.showPicker.
Raises: returns an Error (see web).
Host: Fs_showPicker :: proc(c: ^Call, kind: i32, types: string, multiple: bool, exclude_all: bool, suggested: string, start_in: string, start_root: u64, start_path: string, id: string, readwrite: bool) -> (u64, Api_Error)
Fs_describe
string Fs_describe(u64 root)A root as structuredClone keeps it ("" when unknown).
Odin: fs.describe.
Host: Fs_describe :: proc(c: ^Call, root: u64) -> string
Fs_restore
u64 Fs_restore(string description) raisesThe root a kept description stands for in this realm. Data_Clone for another origin's.
Odin: fs.restore.
Raises: returns an Error (see web).
Host: Fs_restore :: proc(c: ^Call, description: string) -> (u64, Api_Error)