Methods
The accessor is obtained from a running sandbox viasb.FS(). Every method takes a context.Context first and returns an error (wrapped, inspectable with m.IsKind).
fs.Read()
Example
Example
BufferTooSmall on the single-shot path, and this method transparently falls back to ReadStream so callers get a uniform bytes-returning interface up to runtime memory limits.
Parameters
ctxcontext.ContextCancels the read.
pathstringAbsolute path inside the guest, e.g.
“/app/config.json”.Returns
[]byte
File contents.
fs.ReadString()
Example
Example
Parameters
ctxcontext.ContextCancels the read.
pathstringAbsolute path inside the guest.
Returns
string
File contents.
fs.Write()
Example
Example
Parameters
ctxcontext.ContextCancels the write.
pathstringAbsolute path inside the guest.
data[]byteBytes to write.
fs.WriteString()
Example
Example
Write.
Parameters
ctxcontext.ContextCancels the write.
pathstringAbsolute path inside the guest.
contentstringText to write.
fs.List()
Example
Example
Parameters
ctxcontext.ContextCancels the listing.
pathstringAbsolute directory path inside the guest.
Returns
Directory entries.
fs.Stat()
Example
Example
Parameters
ctxcontext.ContextCancels the stat.
pathstringAbsolute path inside the guest.
Returns
File metadata.
fs.Mkdir()
Example
Example
Parameters
ctxcontext.ContextCancels the operation.
pathstringAbsolute directory path inside the guest.
fs.Remove()
Example
Example
RemoveDir for directories.
Parameters
ctxcontext.ContextCancels the operation.
pathstringAbsolute file path inside the guest.
fs.RemoveDir()
Example
Example
Parameters
ctxcontext.ContextCancels the operation.
pathstringAbsolute directory path inside the guest.
fs.Copy()
Example
Example
Parameters
ctxcontext.ContextCancels the operation.
srcstringSource path inside the guest.
dststringDestination path inside the guest.
fs.Rename()
Example
Example
Parameters
ctxcontext.ContextCancels the operation.
srcstringCurrent path inside the guest.
dststringNew path inside the guest.
fs.Exists()
Example
Example
Parameters
ctxcontext.ContextCancels the check.
pathstringAbsolute path inside the guest.
Returns
bool
true if the path exists.fs.CopyFromHost()
Example
Example
Parameters
ctxcontext.ContextCancels the copy.
hostPathstringSource path on the host.
guestPathstringDestination path inside the guest.
fs.CopyToHost()
Example
Example
Parameters
ctxcontext.ContextCancels the copy.
guestPathstringSource path inside the guest.
hostPathstringDestination path on the host.
fs.ReadStream()
Example
Example
Close the returned *FsReadStream. Read falls back to this automatically when a file exceeds the single-shot buffer.
Parameters
ctxcontext.ContextCancels opening the stream.
pathstringAbsolute path inside the guest.
Returns
Open read stream; close it when done.
fs.WriteStream()
Example
Example
Close(ctx) on the returned *FsWriteStream to finalise the write.
Parameters
ctxcontext.ContextCancels opening the stream.
pathstringAbsolute path inside the guest.
Returns
Open write stream;
Close(ctx) it to finalise.Types
FsEntry
Returned by List()
A single directory listing entry.FsEntryKind
Used by FsEntry.Kind
Classifies a directory listing entry. Defined astype FsEntryKind string.
FsStat
Returned by Stat()
Detailed file metadata.FsReadStream
Returned by ReadStream()
An open streaming read from a guest file. Must be closed withClose when done.
On a write error or partial write,
WriteTo and CopyTo return the partial byte count and leave the stream open so the caller can recover; close it explicitly in either case.
FsWriteStream
Returned by WriteStream()
An open streaming write to a guest file. Must be closed withClose(ctx) to finalise the write.