Files in a running sandbox.
Every call goes through the guest's exec agent, so the sandbox has to be running — there is no offline write. Each function takes the machine id, in keeping with the rest of the SDK's functional shape.
Bsdkrun.FileSystem.write_file("web", "/app/main.py", "print('hi')")
{:ok, text} = Bsdkrun.FileSystem.read_file("web", "/app/out.json")
Bsdkrun.FileSystem.upload("web", "./src", "/app/src")
Bsdkrun.FileSystem.download("web", "/app/dist", "./dist", recursive: true)
Summary
Functions
Copy a file or directory out of the guest onto the host.
Read path from the guest, returning {:ok, binary}.
Copy a host file or directory into the guest.
Write data to path in the guest, creating parent directories.
Functions
@spec download(String.t(), String.t(), Path.t(), keyword()) :: :ok | {:error, Bsdkrun.Error.t()}
Copy a file or directory out of the guest onto the host.
Pass recursive: true for a directory; unlike upload/3 it cannot be
detected here, because the path lives in the guest and answering would cost
an extra round trip on every call.
@spec read_file(String.t(), String.t()) :: {:ok, binary()} | {:error, Bsdkrun.Error.t()}
Read path from the guest, returning {:ok, binary}.
The result is a raw binary, so it is equally correct for text and for a PNG.
@spec upload(String.t(), Path.t(), String.t()) :: :ok | {:error, Bsdkrun.Error.t()}
Copy a host file or directory into the guest.
A directory's contents land in remote_path, so
upload(id, "./src", "/app/src") leaves the guest's /app/src holding what
./src holds. Whether it recurses is decided by looking at the local path,
so callers do not have to say which kind of thing they are copying.
@spec write_file(String.t(), String.t(), iodata()) :: :ok | {:error, Bsdkrun.Error.t()}
Write data to path in the guest, creating parent directories.
Returns :ok or {:error, %Bsdkrun.Error{kind: :file_transfer}}.