loadFromStorage static method
Loads an OpfsFileSystem
in the desired path
under the root directory
for OPFS as given by navigator.storage.getDirectory()
in JavaScript.
Throws a FileSystemException 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<OpfsFileSystem> loadFromStorage(String path) async {
final storage = storageManager;
if (storage == null) {
throw FileSystemException(
SqlError.SQLITE_ERROR, 'storageManager not supported by browser');
}
var opfsDirectory = await storage.directory;
for (final segment in p.split(path)) {
opfsDirectory = await opfsDirectory.getDirectory(segment, create: true);
}
return inDirectory(opfsDirectory);
}