SandboxFsOps
Filesystem accessor for a running sandbox. Obtained viaSandbox.FS(). All operations go through the same host-guest channel as command execution — no SSH, no network involved. For bulk file operations, consider using a volume instead.
Read()
BufferTooSmall on the single-shot path; this method transparently falls back to ReadStream so callers get a uniform “Read returns bytes” interface up to runtime memory limits.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | Cancels the read |
| path | string | Absolute path inside the guest (e.g. "/app/config.json") |
| Type | Description |
|---|---|
[]byte | File contents |
ReadString()
Write()
WriteString()
List()
| Type | Description |
|---|---|
[]FsEntry | Directory entries |
Stat()
| Type | Description |
|---|---|
*FsStat | File metadata |
Mkdir()
Remove()
RemoveDir for directories.
RemoveDir()
Copy()
Rename()
Exists()
CopyFromHost()
CopyToHost()
ReadStream()
Close the returned *FsReadStream.
WriteStream()
Close(ctx) on the returned *FsWriteStream to finalise the operation.
Types
FsEntry
A single directory listing entry returned byList.
| Field | Type | Description |
|---|---|---|
| Path | string | File path |
| Kind | FsEntryKind | Entry type |
| Size | int64 | File size in bytes |
| Mode | uint32 | Unix permission bits |
FsEntryKind
| Constant | Value | Description |
|---|---|---|
FsEntryKindFile | "file" | Regular file |
FsEntryKindDirectory | "directory" | Directory |
FsEntryKindSymlink | "symlink" | Symbolic link |
FsEntryKindOther | "other" | Other entry type |
FsStat
Detailed file metadata returned byStat.
| Field | Type | Description |
|---|---|---|
| Path | string | File path |
| Size | int64 | File size in bytes |
| Mode | uint32 | Unix permission bits |
| ModTime | time.Time | Last modified timestamp (zero value if the guest did not report one) |
| IsDir | bool | Whether the path is a directory |
FsReadStream
Streaming file read returned byReadStream. Must be closed when done.
| Method | Returns | Description |
|---|---|---|
Recv(ctx) | ([]byte, error) | Receive the next chunk. Returns (nil, nil) at EOF |
WriteTo(w io.Writer) | (int64, error) | Drain the stream into w using context.Background() — implements io.WriterTo |
CopyTo(ctx, w io.Writer) | (int64, error) | Drain into w with caller-supplied context |
Close() | error | Release the read stream handle |
WriteTo and CopyTo leave the stream open on error and partial writes so the caller can decide how to recover; close it explicitly in either case.
FsWriteStream
Streaming file write returned byWriteStream. Must be closed via Close(ctx) to finalise.
| Method | Returns | Description |
|---|---|---|
Write(p []byte) | (int, error) | Implements io.Writer. Uses context.Background() internally |
WriteCtx(ctx, data []byte) | error | Write with explicit context |
Close(ctx) | error | Send EOF and finalise the file |