SimpleOpfsFileSystem class final

A VirtualFileSystem 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 open both files (done in SimpleOpfsFileSystem.inDirectory or SimpleOpfsFileSystem.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 SimpleOpfsFileSystems are only available in dedicated web workers, not in the JavaScript context for a tab or a shared web worker.

Inheritance

Properties

hashCode int
The hash code for this object.
no setterinherited
name String
The name of this virtual file system.
finalinherited
random Random
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() → void
Closes the synchronous access handles kept open while this file system is active.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
xAccess(String path, int flags) int
Check whether a file can be accessed.
override
xCurrentTime() DateTime
Returns the current time.
inherited
xDelete(String path, int syncDir) → void
Delete a file.
override
xFullPathName(String path) String
Resolves a path name supplied by the user into a path that can be used by the other methods of this VFS.
override
xOpen(Sqlite3Filename path, int flags) XOpenResult
Opens a file, returning supported flags and a file instance.
override
xRandomness(Uint8List target) → void
Fill the target with random bytes.
inherited
xSleep(Duration duration) → void
Sleeps for the passed duration.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

inDirectory(FileSystemDirectoryHandle root, {String vfsName = 'simple-opfs'}) Future<SimpleOpfsFileSystem>
Loads an SimpleOpfsFileSystem in the desired root directory, which must be a Dart wrapper around a FileSystemDirectoryHandle.
loadFromStorage(String path, {String vfsName = 'simple-opfs'}) Future<SimpleOpfsFileSystem>
Loads an SimpleOpfsFileSystem in the desired path under the root directory for OPFS as given by navigator.storage.getDirectory() in JavaScript.