MemoryFileSystem class final
In-memory FileSystem with POSIX-style (/-separated) paths.
Paths are normalized (./.. resolved, duplicate slashes collapsed) and
relative paths are resolved against cwd. Writes and appends create
parent directories automatically, matching the dart:io implementation.
- Implemented types
- Implementers
Constructors
- MemoryFileSystem({String cwd = '/'})
-
Creates a MemoryFileSystem rooted at
cwd(default/).
Properties
Methods
-
absolutePath(
String path) → Future< Result< String, FileError> > -
Returns an absolute addressed path without requiring it to exist and
without resolving symlinks.
override
-
appendFile(
String path, String content) → Future< Result< void, FileError> > -
Creates or appends to a file, creating parent directories.
override
-
createDir(
String path, {bool recursive = true}) → Future< Result< void, FileError> > -
Creates a directory. When
recursiveis true (the default), missing parents are created too.override -
exists(
String path) → Future< Result< bool, FileError> > -
Returns
falsefor missing paths; other errors surface as Err.override -
exportSnapshot(
) → MemoryFsSnapshot -
Deep-copies the whole tree below FileSystem.cwd synchronously.
Traversal order matches a
listDirwalk exactly (depth-first, children sorted by name), so an export of a quiescent tree is identical to an async walk of it.override -
fileInfo(
String path) → Future< Result< FileInfo, FileError> > -
Returns metadata for the addressed path without following symlinks.
override
-
joinPath(
List< String> parts) → Future<Result< String, FileError> > -
Joins path segments in the filesystem namespace without requiring the
result to exist.
override
-
listDir(
String path) → Future< Result< List< >FileInfo> , FileError> -
Lists the direct children of a directory.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readBinaryFile(
String path) → Future< Result< Uint8List, FileError> > -
Reads the file as raw bytes.
override
-
readRange(
String path, int start, int end) → Future< Result< Uint8List, FileError> > -
Reads the bytes of
pathin the half-open range [start, end).override -
readTextFile(
String path) → Future< Result< String, FileError> > -
Reads a UTF-8 text file.
override
-
readTextLines(
String path, {int? maxLines}) → Future< Result< List< >String> , FileError> -
Reads UTF-8 text lines. Implementations should stop once
maxLineslines have been read.override -
remove(
String path, {bool recursive = false, bool force = false}) → Future< Result< void, FileError> > -
Removes a file or directory. With
force, a missing path is not an error.override -
renamePath(
String from, String to) → Future< Result< void, FileError> > -
Atomically renames/moves
fromtoto(overwrites an existingto, POSIX semantics).override -
setMtime(
String path, int mtimeMs) → void -
Test-only: updates the modification time of
pathtomtimeMs. No-op when the file does not exist. -
toString(
) → String -
A string representation of this object.
inherited
-
writeBinaryFile(
String path, Uint8List content) → Future< Result< void, FileError> > -
Writes raw bytes to a file, creating parent directories.
override
-
writeFile(
String path, String content) → Future< Result< void, FileError> > -
Creates or overwrites a file, creating parent directories.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited