VirtualFileSystem

An in-memory FileSystem, detached from the physical disk. Entries produced by this file system return null from FsEntry.toFileOrNull.

Parameters

workingDirectoryPath

absolute path of the working directory within the virtual tree

Constructors

Link copied to clipboard
constructor(workingDirectoryPath: String? = "/")

Properties

Link copied to clipboard
open val isRoot: Boolean

Whether this file system is the root one.

Link copied to clipboard
override val root: FileSystem?

The root file system that originated this one via branch calls. If null, this file system is the root.

Link copied to clipboard
override val workingDirectory: FsEntry?

The working directory of this file system. If not null, resolve will be able to resolve relative paths from this directory.

Functions

Link copied to clipboard
override fun branch(workingDirectory: FsEntry?): FileSystem

Creates a new FileSystem branched from this one, with the given workingDirectory.

Link copied to clipboard
operator override fun equals(other: Any?): Boolean

File systems are compared by value: same backend, working directory, and branch lineage. This mirrors the behavior expected by recursive AST comparisons.

Link copied to clipboard
override fun hashCode(): Int
Link copied to clipboard
fun mkdirs(path: String)

Creates a directory at path (relative to the working directory, or absolute), including any missing parent directories.

Link copied to clipboard
override fun relativePathTo(other: FileSystem): FsEntry?

Computes the relative path from this file system's workingDirectory to other's.

Link copied to clipboard
override fun reroot(workingDirectory: FsEntry?): FileSystem

Creates a new root FileSystem on the same backend, with the given workingDirectory and no branch lineage, so that isRoot holds for the result.

Link copied to clipboard
override fun resolve(path: String): FsEntry

Resolves a local file path, either absolutely or relatively from workingDirectory. This does not perform any check for file existence.

Link copied to clipboard
fun write(path: String, content: String)

Writes UTF-8 content to the file at path (relative to the working directory, or absolute), creating missing parent directories.

Link copied to clipboard
fun writeBytes(path: String, content: ByteArray)

Writes raw content bytes to the file at path (relative to the working directory, or absolute), creating missing parent directories.