MemoryFileSystem class abstract
An implementation of FileSystem that exists entirely in memory with an internal representation loosely based on the Filesystem Hierarchy Standard.
MemoryFileSystem is suitable for mocking and tests, as well as for caching or staging before writing or reading to a live system.
This implementation of the FileSystem interface does not directly use
any dart:io
APIs; it merely uses the library's enum values and interfaces.
As such, it is suitable for use in the browser.
- Implemented types
- Available extensions
Constructors
- MemoryFileSystem.new({FileSystemStyle style = FileSystemStyle.posix, void opHandle(String context, FileSystemOp operation) = _defaultOpHandle})
-
Creates a new
MemoryFileSystem
.factory - MemoryFileSystem.test({FileSystemStyle style = FileSystemStyle.posix, void opHandle(String context, FileSystemOp operation) = _defaultOpHandle})
-
Creates a new
MemoryFileSystem
that has a fake clock.factory
Properties
- currentDirectory ↔ Directory
-
Creates a directory object pointing to the current working directory.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isWatchSupported → bool
-
Tests if FileSystemEntity.watch is supported on the current system.
no setterinherited
- path → Context
-
An object for manipulating paths in this file system.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → FileSystemStyle
-
The style used by this file system.
no setterinherited
- systemTempDirectory → Directory
-
Gets the system temp directory.
no setterinherited
Methods
-
atomicMove(
String source, String target) → Future< void> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Movessource
totarget
in-place if the underlying file system supports it. Iftarget
exists, it is first removed. Ifsource == target
, this operation does nothing. This may be used to move a file or a directory. -
copy(
String source, String target, {bool followLinks = true}) → Future< FileSystemEntity> -
Available on FileSystem, provided by the FileSystemShortcuts extension
-
createDirectory(
dynamic path, {bool recursive = false}) → Future< Directory> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Creates the directory if it doesn't exist. -
createDirectorySync(
{bool recursive = false}) → void -
Available on FileSystem, provided by the FileSystemShortcuts extension
Synchronously creates the directory if it doesn't exist. -
createLink(
dynamic path, {bool recursive = false}) → Future< Link> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Creates a symbolic link in the file system. -
createLinkSync(
dynamic path, {bool recursive = false}) → void -
Available on FileSystem, provided by the FileSystemShortcuts extension
Creates a symbolic link in the file system. -
delete(
String path, {bool mustExist = false}) → Future< void> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Deletes the FileSystemEntity reference bypath
. -
deleteSync(
String path, {bool mustExist = false}) → void -
Available on FileSystem, provided by the FileSystemShortcuts extension
Synchronously deletes the FileSystemEntity reference bypath
. -
directory(
dynamic path) → Directory -
Returns a reference to a Directory at
path
.inherited -
entity(
String path) → Future< FileSystemEntity?> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Returns a reference to a FileSystemEntity atpath
. -
entitySync(
String path) → FileSystemEntity? -
Available on FileSystem, provided by the FileSystemShortcuts extension
Synchronously returns a reference to a FileSystemEntity atpath
. -
exists(
String path) → Future< bool> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Checks whether the file system entity with thispath
exists. -
existsSync(
String path) → bool -
Available on FileSystem, provided by the FileSystemShortcuts extension
Synchronously checks whether the file system entity with thispath
exists. -
file(
dynamic path) → File -
Returns a reference to a File at
path
.inherited -
getPath(
dynamic path) → String -
Gets the string path represented by the specified generic
path
.inherited -
identical(
String path1, String path2) → Future< bool> -
Checks whether two paths refer to the same object in the
file system. Returns a Future<bool> that completes with the result.
inherited
-
identicalSync(
String path1, String path2) → bool -
Synchronously checks whether two paths refer to the same object in the
file system.
inherited
-
isCivilized(
String path) → Future< bool> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Returns true if file streams can be manipulated independently of their paths. This is typically true for systems like Mac, Unix, and Linux that use inodes in their file system interface. It is typically false on Windows. -
isDirectory(
String path) → Future< bool> -
Checks if
type(path)
returnsio.FileSystemEntityType.DIRECTORY
.inherited -
isDirectorySync(
String path) → bool -
Synchronously checks if
type(path)
returnsio.FileSystemEntityType.DIRECTORY
.inherited -
isFile(
String path) → Future< bool> -
Checks if
type(path)
returnsio.FileSystemEntityType.FILE
.inherited -
isFileSync(
String path) → bool -
Synchronously checks if
type(path)
returnsio.FileSystemEntityType.FILE
.inherited -
isLink(
String path) → Future< bool> -
Checks if
type(path)
returnsio.FileSystemEntityType.LINK
.inherited -
isLinkSync(
String path) → bool -
Synchronously checks if
type(path)
returnsio.FileSystemEntityType.LINK
.inherited -
link(
dynamic path) → Link -
Returns a reference to a Link at
path
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
open(
dynamic path, {FileMode mode = FileMode.read, bool recursive = false}) → Future< FileHandle> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Creates aFileHandle
to handlepath
. -
openSink(
dynamic path, {int position = 0, bool recursive = false}) → Future< Sink> -
Available on FileSystem, provided by the FileSystemShortcuts extension
-
openSource(
dynamic path, {int position = 0}) → Future< Source> -
Available on FileSystem, provided by the FileSystemShortcuts extension
-
read<
T> (String path, FutureOr< T> block(BufferedSource source), [int? start, int? end]) → Future<T> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Creates a source to readpath
, executesblock
to read it, and then closes the source. This is a compact way to read the contents of a file. -
sink(
String path, {FileMode mode = FileMode.write, bool recursive = false}) → Future< Sink> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Creates aSink
that writes bytes topath
from beginning to end. Ifpath
already exists it will be replaced with the new data. -
source(
String path, [int? start, int? end]) → Future< Source> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Creates a source that reads the bytes ofpath
from beginning to end. -
stat(
String path) → Future< FileStat> -
Asynchronously calls the operating system's stat() function on
path
. Returns a Future which completes with a io.FileStat object containing the data returned by stat(). If the call fails, completes the future with a io.FileStat object with .type set to FileSystemEntityType.NOT_FOUND and the other fields invalid.inherited -
statSync(
String path) → FileStat -
Calls the operating system's stat() function on
path
. Returns a io.FileStat object containing the data returned by stat(). If the call fails, returns a io.FileStat object with .type set to FileSystemEntityType.NOT_FOUND and the other fields invalid.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
type(
String path, {bool followLinks = true}) → Future< FileSystemEntityType> -
Finds the type of file system object that a
path
points to. Returns a Futureinherited -
typeSync(
String path, {bool followLinks = true}) → FileSystemEntityType -
Syncronously finds the type of file system object that a
path
points to. Returns a io.FileSystemEntityType.inherited -
write<
T> (String path, FutureOr< T> block(BufferedSink sink), {FileMode mode = FileMode.write, bool recursive = false}) → Future<T> -
Available on FileSystem, provided by the FileSystemShortcuts extension
Creates a sink to writepath
, executesblock
to write it, and then closes the sink. This is a compact way to write a file.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited