InMemoryVfs class final

A stateful, byte-backed Vfs.

Scripted results are FIFO and short-circuit the corresponding operation, which supports deterministic fault injection without a mocking framework.

Implemented types

Constructors

InMemoryVfs({Map<String, List<int>> files = const <String, List<int>>{}, Iterable<String> directories = const <String>['/'], DateTime? modifiedAt})
Creates a filesystem fake seeded with files and directories.

Properties

directories Set<String>
Snapshot of the stored directories.
no setter
files Map<String, List<int>>
Snapshot of the stored files, deeply unmodifiable.
no setter
hashCode int
The hash code for this object.
no setterinherited
modifiedAt DateTime
Modified instant reported for every entry.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createDirectory(String path, {bool recursive = false}) Future<Result<void>>
Creates the directory at path.
override
delete(String path, {bool recursive = false}) Future<Result<void>>
Deletes the file or directory at path.
override
enqueueCreateDirectoryResult(Result<void> result) → void
Scripts the next createDirectory answer.
enqueueDeleteResult(Result<void> result) → void
Scripts the next delete answer.
enqueueExistsResult(Result<bool> result) → void
Scripts the next exists answer.
enqueueListResult(Result<List<VfsEntry>> result) → void
Scripts the next list answer.
enqueueReadBytesResult(Result<List<int>> result) → void
Scripts the next readBytes answer.
enqueueReadTextResult(Result<String> result) → void
Scripts the next readText answer.
enqueueStatResult(Result<VfsStat> result) → void
Scripts the next stat answer.
enqueueWriteBytesResult(Result<void> result) → void
Scripts the next writeBytes answer.
enqueueWriteTextResult(Result<void> result) → void
Scripts the next writeText answer.
exists(String path) Future<Result<bool>>
Reports whether path resolves to anything.
override
list(String path, {bool recursive = false}) Future<Result<List<VfsEntry>>>
Lists the entries directly (or, when recursive, transitively) under path.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readBytes(String path) Future<Result<List<int>>>
Reads path as bytes.
override
readText(String path) Future<Result<String>>
Reads path as UTF-8 text.
override
stat(String path) Future<Result<VfsStat>>
Describes path without listing its parent.
override
toString() String
A string representation of this object.
inherited
writeBytes(String path, List<int> bytes, {bool createParents = false}) Future<Result<void>>
Writes bytes to path, optionally creating missing parents.
override
writeText(String path, String content, {bool createParents = false}) Future<Result<void>>
Writes content to path as UTF-8, optionally creating missing parents.
override

Operators

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

Static Methods

normalizePath(String path) String
Collapses empty segments and forces a leading slash.