loadFromStorage static method
Loads an SimpleOpfsFileSystem in the desired path
under the root directory
for OPFS as given by navigator.storage.getDirectory()
in JavaScript.
Throws a VfsException if OPFS is not available - please note that this file system implementation requires a recent browser and only works in dedicated web workers.
Implementation
static Future<SimpleOpfsFileSystem> loadFromStorage(String path,
{String vfsName = 'simple-opfs'}) async {
final storage = storageManager;
if (storage == null) {
throw VfsException(SqlError.SQLITE_ERROR);
}
var opfsDirectory = await storage.directory;
for (final segment in p.split(path)) {
opfsDirectory = await opfsDirectory.getDirectory(segment, create: true);
}
return inDirectory(opfsDirectory, vfsName: vfsName);
}