alignment/file_io

BEAM file I/O — typed wrappers around erlang:file externals.

Every @external lives here. Other modules call typed functions like read_text, read_binary, write_text, mkdir, delete_path. No @external leaks into CLI or pipeline modules.

Types

pub type FileError {
  NotFound
  PermissionDenied
  DecodeFailed
  Unknown(String)
}

Constructors

  • NotFound
  • PermissionDenied
  • DecodeFailed
  • Unknown(String)

Values

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

Delete a file. Returns Ok even if file doesn’t exist (safe cleanup).

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

Create a directory. Safe to call if it already exists.

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

Read a binary file as BitArray.

pub fn read_text(path: String) -> Result(String, FileError)

Read a text file as String.

pub fn write_text(
  path: String,
  content: String,
) -> Result(Nil, FileError)

Write a String to a file.

✨ Search Document