FileSystemOpfsWeb.withFileHandles constructor

FileSystemOpfsWeb.withFileHandles(
  1. List<FileSystemOpfsWebFileHandle> fileHandles
)

File system whose root "directory" contains exactly fileHandles, each at /<name> (name being the JS handle name, deduplicated as name (1), name (2), ... on collision).

fileHandles are typically obtained from showOpenFilePicker or showSaveFilePicker (Chromium-only) or by wrapping JS FileSystemFileHandles in FileSystemOpfsWebFileHandles.

final handles = await FileSystemOpfsWeb.showOpenFilePicker(
    FileSystemOpfsWebShowOpenFilePickerOptions(multiple: true));
final fs = FileSystemOpfsWeb.withFileHandles(handles);
await for (final file in fs.directory('/').list()) {
  print(await fs.file(file.path).readAsString());
}

File handles give no access to their parent directory, so the structure is fixed: the files can be read, written (permission permitting) and copied to each other, but not created, deleted or renamed, and no directory can be created. Handles from showSaveFilePicker are writable; showOpenFilePicker handles are read-only unless granted readwrite permission (see requestWritePermission).

Only available on the web. Links and random access are not supported.

Implementation

factory FileSystemOpfsWeb.withFileHandles(
  List<FileSystemOpfsWebFileHandle> fileHandles,
) => fileSystemOpfsWebWithFileHandlesImpl(fileHandles);