TomMemoryFileSystem class

Files and folders keyed by their absolute path. Writes are atomic by construction, revisions are checked like on disk, there is no trash, and watch reports every change made through it.

Inheritance
Available extensions

Constructors

TomMemoryFileSystem({Uri? root, Map<String, String> seed = const {}})
root defaults to /; seed maps absolute paths to text.

Properties

hashCode → int
The hash code for this object.
no setterinherited
onDidChange → Stream<TomFileChangeEvent>
Every create, write, rename and delete made through this file system.
no setterinherited
onDidSave → Stream<Uri>
no setterinherited
onWillSave → Stream<TomWillSaveEvent>
no setterinherited
paths → List<String>
The paths of every file, sorted — for tests.
no setter
root → Uri
The root directory, as an absolute directory URI (trailing /).
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

absolute(Uri uri) → Uri
uri made absolute against root.
inherited
create(Uri uri, {bool directory = false}) → Future<void>
Creates an empty file, or with directory a folder with its parents. A file that already exists is refused.
override
delete(Uri uri) → Future<void>
Deletes uri for good — a folder with everything in it.
override
dispose() → Future<void>
Ends the event streams.
override
emitChange(Uri uri, TomFileChangeType type) → void
Announces a change made through this file system.
inherited
ensureFolder(Uri folder) → Future<void>

Available on TomFileSystem, provided by the TomFileSystemFolders extension

Makes folder (and its parents) when it does not exist.
exists(Uri uri) → Future<bool>
Whether uri exists.
override
folderOf(Uri uri) → Uri

Available on TomFileSystem, provided by the TomFileSystemFolders extension

The folder holding uri.
list(Uri directory) → Future<List<TomFileEntry>>
The entries of the directory directory — one level, unsorted.
override
nameOf(Uri uri) → String
The last segment of uri's path — a file's or folder's own name.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pathOf(Uri uri) → String?
uri's path relative to root, or null when it lies outside it.
inherited
read(Uri uri) → Future<TomFileContent>
The bytes of uri and the revision they were read at.
override
readSlice(Uri uri, {required int maxBytes, required bool fromEnd}) → Future<String?>
At most maxBytes of uri as text, from its end when fromEnd and from its start otherwise — or null when it does not exist.
override
readText(Uri uri) → Future<String>
The text of uri, decoded as UTF-8.
inherited
readTextIfExists(Uri uri) → Future<String?>

Available on TomFileSystem, provided by the TomFileSystemFolders extension

The text of uri, or null when it does not exist.
rename(Uri from, Uri to) → Future<void>
Renames or moves from to to; an existing to is refused.
override
save(Uri uri) → Future<void>
Announces that uri is saved: onWillSave with its text, then onDidSave.
inherited
stat(Uri uri) → Future<TomFileEntry?>
uri's entry without reading it, or null when it does not exist.
override
toString() → String
A string representation of this object.
inherited
trash(Uri uri) → Future<bool>
There is no trash in memory: the caller asks before delete.
override
uriOf(String path) → Uri
The absolute URI of path, relative to root with / separators.
inherited
watch({bool descend(String path)?}) → Stream<TomFileChange>?
Changes under root, or null when the platform refuses to watch.
override
write(Uri uri, Uint8List bytes, {TomFileRevision? expected}) → Future<TomFileRevision>
Writes bytes to uri atomically. With expected, refuses with a TomFileConflict when the file is no longer that revision. Answers the revision written.
override
writeText(Uri uri, String text, {TomFileRevision? expected}) → Future<TomFileRevision>
write of text as UTF-8.
inherited
writeTextMakingFolder(Uri uri, String text) → Future<TomFileRevision>

Available on TomFileSystem, provided by the TomFileSystemFolders extension

writeText of text to uri, making its folder first when it is missing.

Operators

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