SandboxFsOps
fs.read()
Example
Example
Parameters
pathstringAbsolute path inside the guest (e.g.
“/app/config.json”).Returns
Promise<Uint8Array>
File contents as raw bytes.
fs.readToString()
Example
Example
Parameters
pathstringAbsolute path inside the guest.
Returns
Promise<string>
File contents as a string.
fs.write()
Example
Example
string payloads are encoded as UTF-8.
Parameters
pathstringAbsolute path inside the guest.
dataUint8Array | stringFile content. Strings are written as UTF-8.
fs.readStream()
Example
Example
FsReadStream is an AsyncIterable<Uint8Array>, so it works with for await...of.
Parameters
pathstringAbsolute path inside the guest.
Returns
Async stream that yields chunks of file data.
fs.writeStream()
Example
Example
await using so the FsWriteSink closes itself when the scope exits.
Parameters
pathstringAbsolute path inside the guest.
Returns
Streaming writer.
fs.list()
Example
Example
Parameters
pathstringAbsolute directory path inside the guest.
Returns
Directory entries.
fs.mkdir()
Example
Example
Parameters
pathstringAbsolute directory path.
fs.removeDir()
Example
Example
Parameters
pathstringAbsolute directory path.
fs.remove()
Example
Example
Parameters
pathstringAbsolute file path.
fs.stat()
Example
Example
Parameters
pathstringAbsolute path inside the guest.
Returns
File metadata.
fs.exists()
Example
Example
Parameters
pathstringAbsolute path inside the guest.
Returns
Promise<boolean>
true if the path exists.fs.copy()
Example
Example
Parameters
fromstringSource path.
tostringDestination path.
fs.rename()
Example
Example
Parameters
fromstringCurrent path.
tostringNew path.
fs.copyFromHost()
Example
Example
Parameters
hostPathstringPath on the host filesystem.
guestPathstringDestination path inside the sandbox.
fs.copyToHost()
Example
Example
Parameters
guestPathstringPath inside the sandbox.
hostPathstringDestination path on the host.
FsReadStream
Returned by readStream()
Async stream for reading a file in chunks. ImplementsAsyncIterable<Uint8Array> and AsyncDisposable, so it works with for await...of and await using.
stream.recv()
null when the file has been fully read.
Returns
Promise<Uint8Array \| null>
stream.collect()
Returns
Promise<Uint8Array>
stream.Symbol.asyncIterator
for await...of
Returns
AsyncIterator<Uint8Array>
stream.Symbol.asyncDispose
await using scope exit
Returns
Promise<void>
FsWriteSink
Returned by writeStream()
Streaming writer for a file. ImplementsAsyncDisposable, so it can be paired with await using.
sink.write()
Returns
Promise<void>
sink.close()
Returns
Promise<void>
sink.Symbol.asyncDispose
close() on await using scope exit
Returns
Promise<void>
Types
FsEntry
Returned by list()
Metadata for a single directory entry.FsMetadata
Returned by stat()
Detailed file metadata.FsEntryKind
Used by FsEntry.kind · FsMetadata.kind