thrifty/file_io

Values

pub fn ensure_dir(path: String) -> Result(Nil, String)

Ensure a directory exists, creating it if necessary.

Returns Ok(Nil) on success or Error(String) on failure.

pub fn read_binary(path: String) -> Result(BitArray, String)

Read the binary contents at path returning a Gleam BitArray.

Inputs

  • path: filesystem path to the file to read.

Outputs

  • Ok(BitArray) containing the file contents on success.
  • Error(String) with a human-readable reason on failure.

Error modes

  • The function converts Erlang atoms returned by the underlying call into strings for easier consumption by tests and higher-level code.
pub fn write_binary_to_path(
  path: String,
  data: BitArray,
) -> Result(Nil, String)

Write binary contents to path.

Inputs

  • path: filesystem path where to write the data.
  • data: BitArray to write to disk.

Outputs

  • Ok(Nil) on success.
  • Error(String) with a human-readable reason on failure.
Search Document