SandboxFsOps
fs.read()
Example
Example
Parameters
pathstrAbsolute path inside the guest, e.g.
“/app/config.json”.Returns
bytes
File contents as raw bytes.
fs.read_text()
Example
Example
Parameters
pathstrAbsolute path inside the guest.
Returns
str
File contents decoded as UTF-8.
fs.read_stream()
Example
Example
FsReadStream is an async iterator that yields chunks of bytes, or call its collect() to gather everything into one bytes.
Parameters
pathstrAbsolute path inside the guest.
Returns
Async iterator yielding chunks of file data.
fs.write()
Example
Example
Parameters
pathstrAbsolute path inside the guest.
databytesFile content.
fs.write_stream()
Example
Example
FsWriteSink supports the async context manager protocol, so async with closes and finalizes the file automatically.
Parameters
pathstrAbsolute path inside the guest.
Returns
Async writer that accepts chunks of bytes.
fs.list()
Example
Example
Parameters
pathstrAbsolute directory path inside the guest.
Returns
Directory entries.
fs.mkdir()
Example
Example
Parameters
pathstrAbsolute directory path inside the guest.
fs.stat()
Example
Example
Parameters
pathstrAbsolute path inside the guest.
Returns
File metadata.
fs.exists()
Example
Example
Parameters
pathstrAbsolute path inside the guest.
Returns
bool
True if the path exists.fs.remove_dir()
Example
Example
Parameters
pathstrAbsolute directory path inside the guest.
fs.copy()
Example
Example
Parameters
srcstrSource path inside the guest.
dststrDestination path inside the guest.
fs.rename()
Example
Example
Parameters
srcstrCurrent path inside the guest.
dststrNew path inside the guest.
fs.remove()
Example
Example
remove_dir() for directories.
Parameters
pathstrAbsolute file path inside the guest.
fs.copy_from_host()
Example
Example
Parameters
host_pathstrPath on the host filesystem.
guest_pathstrDestination path inside the sandbox.
fs.copy_to_host()
Example
Example
Parameters
guest_pathstrPath inside the sandbox.
host_pathstrDestination path on the host.
FsReadStream
Returned by read_stream()
Async stream for reading a file in chunks. Obtained viaread_stream(). Iterate it with async for chunk in stream:, or call collect() to gather everything at once.
stream.aiter()
async for chunk in stream:.
Returns
bytes
stream.anext()
async for chunk in stream:.
Returns
bytes
stream.collect()
bytes object
Returns
bytes
FsWriteSink
Returned by write_stream()
Async writer for streaming data into a file. Obtained viawrite_stream(). Supports the async context manager protocol, so async with closes the sink on exit.
sink.write()
bytes to the file
sink.close()
sink.aenter()
async with for automatic close on exit
Returns
FsWriteSink
sink.aexit()
async with for automatic close on exit
Returns
FsWriteSink
Types
FsEntry
Returned by list()
Metadata for a single directory entry, returned bylist().
FsEntryKind
Describes FsEntry.kind · FsMetadata.kind
Filesystem entry type returned byFsEntry.kind and FsMetadata.kind.
FsMetadata
Returned by stat()
Detailed file metadata, returned bystat().