Skip to main content
See Filesystem for usage examples.

Sandbox

sandbox.fs

Get the filesystem helper for this sandbox.

Returns

Microsandbox::Filesystem
Guest filesystem operations.

Filesystem

These helpers also have direct sandbox equivalents: sandbox.fs_read, fs_write, fs_mkdir, fs_list, fs_stat, fs_exists?, fs_copy, fs_rename, fs_remove, fs_remove_dir, fs_copy_from_host, and fs_copy_to_host, with the same arguments and return values.

fs.read()

Read file bytes.

Parameters

pathString
Guest path.

Returns

String
Read file bytes.

fs.write()

Write a Ruby string as bytes.

Parameters

pathString
Guest path.
dataString
File contents as bytes.

Returns

nil
No return value.

fs.mkdir()

Create a guest directory.

Parameters

pathString
Guest path.

Returns

nil
No return value.

fs.list()

List directory entries.

Parameters

pathString
Guest path.

Returns

Array<Hash>
List directory entries.

fs.stat()

Read metadata.

Parameters

pathString
Guest path.

Returns

Hash
Read metadata.

fs.exists?()

Check whether a path exists.

Parameters

pathString
Guest path.

Returns

Boolean
Check whether a path exists.

fs.copy()

Copy within the guest.

Parameters

fromString
Source guest path.
toString
Destination guest path.

Returns

nil
No return value.

fs.rename()

Rename within the guest.

Parameters

fromString
Source guest path.
toString
Destination guest path.

Returns

nil
No return value.

fs.remove()

Remove a file.

Parameters

pathString
Guest path.

Returns

nil
No return value.

fs.remove_dir()

Remove a directory.

Parameters

pathString
Guest path.

Returns

nil
No return value.

fs.copy_from_host()

Transfer from host to guest.

Parameters

host_pathString
Path on the host.
guest_pathString
Path inside the guest.

Returns

nil
No return value.

fs.copy_to_host()

Transfer from guest to host.

Parameters

guest_pathString
Path inside the guest.
host_pathString
Path on the host.

Returns

nil
No return value.

Metadata

Hashes use string keys. Optional timestamps are omitted when unavailable. Ruby does not expose streaming filesystem handles.

Fields

”path”String
Entry path; returned by list
”kind”String
file, directory, symlink, or other
”size”Integer
Size in bytes
”mode”Integer
File mode
”uid”, “gid”Integer
Owner and group IDs
”modified”, “accessed”String
RFC 3339 timestamps, when available
”readonly”Boolean
Returned by stat
”created”String
Creation timestamp, when available from stat