ChrootFileSystem class

File system that provides a view into another FileSystem via a path.

This is similar in concept to the chroot operation in Linux operating systems. Such a modified file system cannot name or access files outside of the designated directory tree.

Example use:

// Create a "file system" where the root directory is /tmp/some-dir.
var fs = ChrootFileSystem(existingFileSystem, '/tmp/some-dir');

Notes on usage:

  • This file system maintains its own currentDirectory, distinct from that of the underlying file system, and new instances automatically start at the root (i.e. /).

  • This file system does not leverage any underlying OS system calls (such as chroot itself), so the developer needs to take care to not assume any more of a secure environment than is actually provided. For instance, the underlying system is available via the delegate - which underscores this file system is intended to be a convenient abstraction, not a security measure.

  • This file system necessarily carries certain performance overhead due to the fact that symbolic links are resolved manually (not delegated).

Inheritance

Constructors

ChrootFileSystem(FileSystem delegate, String root)
Creates a new file system backed by root path in delegate file system. [...]

Properties

currentDirectory Directory
Creates a directory object pointing to the current working directory. [...]
read / write, override
delegate FileSystem
Underlying file system.
final
isWatchSupported bool
Tests if FileSystemEntity.watch is supported on the current system.
read-only, override
path Context
An object for manipulating paths in this file system.
read-only, override
root String
Directory in delegate file system that is treated as the root here.
final
systemTempDirectory Directory
Gets the system temp directory. This directory will be created on-demand in the local root of the file system. Once created, its location is fixed for the life of the process.
read-only, override
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

directory(dynamic path) Directory
Returns a reference to a Directory at path. [...]
override
file(dynamic path) File
Returns a reference to a File at path. [...]
override
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. [...]
override
identicalSync(String path1 String path2) bool
Synchronously checks whether two paths refer to the same object in the file system. [...]
override
Returns a reference to a Link at path. [...]
override
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.
override
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.
override
type(String path, { bool followLinks: true }) Future<FileSystemEntityType>
Finds the type of file system object that a path points to. Returns a Future that completes with the result. [...]
override
typeSync(String path, { bool followLinks: true }) FileSystemEntityType
Syncronously finds the type of file system object that a path points to. Returns a io.FileSystemEntityType. [...]
override
getPath(dynamic path) String
Gets the string path represented by the specified generic path. [...]
@protected, inherited
isDirectory(String path) Future<bool>
Checks if type(path) returns io.FileSystemEntityType.DIRECTORY.
inherited
isDirectorySync(String path) bool
Synchronously checks if type(path) returns io.FileSystemEntityType.DIRECTORY.
inherited
isFile(String path) Future<bool>
Checks if type(path) returns io.FileSystemEntityType.FILE.
inherited
isFileSync(String path) bool
Synchronously checks if type(path) returns io.FileSystemEntityType.FILE.
inherited
Checks if type(path) returns io.FileSystemEntityType.LINK.
inherited
isLinkSync(String path) bool
Synchronously checks if type(path) returns io.FileSystemEntityType.LINK.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited