FileSystem

Access to the current computer's storage. Paths are independent lexical values.

Functions

Link copied to clipboard

Creates missing ancestors. Each directory creation is a separate atomic operation.

Link copied to clipboard
Link copied to clipboard
fun delete(path: Path)

Deletes a file or empty directory; never recursively removes children.

Link copied to clipboard
Link copied to clipboard
fun list(path: Path, maximumEntries: Int = 256): List<Path>

A bounded collection of sorted child paths from one directory snapshot.

Link copied to clipboard
fun move(source: Path, destination: Path)
fun move(source: Path, destination: Path, replaceExisting: Boolean)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Starts a private replacement draft. Closing it aborts; only commit publishes.

Link copied to clipboard
fun readBytes(path: Path, maximumBytes: Int = 65536): ByteArray
Link copied to clipboard
fun readLines(path: Path, maximumBytes: Int = 65536): List<String>

Reads all strict UTF-8 lines from one snapshot, within the encoded file-size bound. LF, CRLF and CR are removed. Empty files have no lines; a final delimiter adds no extra line.

Link copied to clipboard
fun readText(path: Path, maximumBytes: Int = 65536): String

Strict UTF-8; the bound is the encoded byte size, independently of Guest heap quotas.

Link copied to clipboard
fun stat(path: Path): FileInfo
Link copied to clipboard
fun statOrNull(path: Path): FileInfo?

Only a missing entry returns null. Permission and storage failures still throw.

Link copied to clipboard
inline fun <R> useLines(path: Path, maximumLineBytes: Int = 65536, block: (Sequence<String>) -> R): R

Processes strict UTF-8 lines lazily and closes the snapshot reader after block, including failure and non-local return. The sequence can be traversed once and is usable only inside the block.

Link copied to clipboard
fun writeBytes(path: Path, contents: ByteArray)
Link copied to clipboard
fun writeText(path: Path, contents: String)

Strict UTF-8, atomically replacing the entire file. Invalid surrogates never publish.