bsdkrun/filesystem

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 shape.

import bsdkrun/filesystem

let assert Ok(Nil) = filesystem.write_text("web", "/app/main.py", "print(1)")
let assert Ok(bytes) = filesystem.read_file("web", "/app/out.json")
let assert Ok(Nil) = filesystem.upload("web", "./src", "/app/src")
let assert Ok(Nil) = filesystem.download("web", "/app/dist", "./dist", True)

Values

pub fn download(
  id: String,
  remote_path: String,
  local_path: String,
  recursive: Bool,
) -> Result(Nil, error.Error)

Copy a file or directory out of the guest onto the host. recursive selects a directory.

pub fn read_file(
  id: String,
  path: String,
) -> Result(BitArray, error.Error)

Read path from the guest as bytes.

pub fn read_text(
  id: String,
  path: String,
) -> Result(String, error.Error)

Read path from the guest and decode it as UTF-8.

pub fn upload(
  id: String,
  local_path: String,
  remote_path: String,
  recursive: Bool,
) -> Result(Nil, error.Error)

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. Pass recursive for a directory: unlike the other SDKs this is explicit, because Gleam has no stat in its standard library.

pub fn write_file(
  id: String,
  path: String,
  data: BitArray,
) -> Result(Nil, error.Error)

Write data to path in the guest, creating parent directories.

pub fn write_text(
  id: String,
  path: String,
  text: String,
) -> Result(Nil, error.Error)

Write text to path in the guest.

Search Document