OpfsFileSystem class
A FileSystem for the sqlite3
wasm library based on the file system access API.
By design, this file system can only store two files: /database
and
/database-journal
. Thus, when this file system is used, the only sqlite3
database that will be persisted properly is the one at /database
.
The limitation of only being able to store two files comes from the fact that we can't synchronously open files in with the file system access API, only reads and writes are synchronous. By having a known amount of files to store, we can simply open both files in OpfsFileSystem.inDirectory or OpfsFileSystem.loadFromStorage, which is asynchronous too. The actual file system work, which needs to be synchronous for sqlite3 to function, does not need any further wrapper.
Please note that OpfsFileSystems are only available in dedicated web workers, not in the JavaScript context for a tab or a shared web worker.
- Implemented types
Properties
Methods
-
clear(
) → void -
Deletes all files stored in this file system.
override
-
close(
) → void -
createFile(
String path, {bool errorIfNotExists = false, bool errorIfAlreadyExists = false}) → void -
Creates an empty file at
path
.override -
createTemporaryFile(
) → String -
Creates a temporary file with a unique name.
override
-
deleteFile(
String path) → void -
Deletes a file at
path
if it exists, throwing a FileSystemException otherwise.override -
exists(
String path) → bool -
Whether a file at
path
exists.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
read(
String path, Uint8List target, int offset) → int -
Reads a chunk of the file at
path
and offsetoffset
into thetarget
buffer.override -
sizeOfFile(
String path) → int -
Returns the size of a file at
path
if it exists.override -
toString(
) → String -
A string representation of this object.
inherited
-
truncateFile(
String path, int length) → void -
Sets the size of the file at
path
tolength
.override -
write(
String path, Uint8List bytes, int offset) → void -
Writes a chunk from
bytes
into the file at pathpath
and offsetoffset
.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
inDirectory(
Object root) → Future< OpfsFileSystem> -
Loads an OpfsFileSystem in the desired
root
directory, which must be a Dart wrapper around a FileSystemDirectoryHandle. -
loadFromStorage(
String path) → Future< OpfsFileSystem> -
Loads an OpfsFileSystem in the desired
path
under the root directory for OPFS as given bynavigator.storage.getDirectory()
in JavaScript.