A file system utility object for performing read, write, delete, erase, list, and make directory operations on either OPFS (Origin Private File System) or IDBFS (IndexedDB File System).
Methods
del(path, filesystemopt) → {Promise.<any>}
Deletes a file at the specified path in the chosen filesystem.
Parameters
-
path
stringThe path of the file to delete.
-
filesystem
string<optional>
"opfs"The filesystem to use ("opfs" or "idbfs").
Returns
-
Promise.<any>A promise that resolves when the delete operation is complete.
Source
erase(filesystemopt) → {Promise.<any>}
Erases the entire filesystem.
Parameters
-
filesystem
string<optional>
"idbfs"The filesystem to erase ("opfs" or "idbfs").
Returns
-
Promise.<any>A promise that resolves when the erase operation is complete.
Source
ls(path, filesystemopt) → {Promise.<any>}
Lists the contents of a directory at the specified path in the chosen filesystem.
Parameters
-
path
stringThe path of the directory to list.
-
filesystem
string<optional>
"opfs"The filesystem to use ("opfs" or "idbfs").
Returns
-
Promise.<any>A promise that resolves with the contents of the directory.
Source
mkdir(path, filesystemopt) → {Promise.<any>}
Creates a directory at the specified path in the chosen filesystem.
Parameters
-
path
stringThe path of the directory to create.
-
filesystem
string<optional>
"opfs"The filesystem to use ("opfs" or "idbfs").
Returns
-
Promise.<any>A promise that resolves when the directory is created.
Source
read(path, filesystemopt) → {Promise.<any>}
Reads a file from the specified path in the chosen filesystem.
Parameters
-
path
stringThe path of the file to read.
-
filesystem
string<optional>
"opfs"The filesystem to use ("opfs" or "idbfs").
Returns
-
Promise.<any>A promise that resolves with the file's content.
Source
write(path, data, filesystemopt) → {Promise.<any>}
Writes data to a file at the specified path in the chosen filesystem.
Parameters
-
path
stringThe path of the file to write.
-
data
anyThe data to write to the file.
-
filesystem
string<optional>
"opfs"The filesystem to use ("opfs" or "idbfs").
Returns
-
Promise.<any>A promise that resolves when the write operation is complete.