docs / fs

fs

Types

DirEntry

DirEntry(Str, FileType)

FileType

File
Directory
Symlink

IoError

NotFound(Path)
PermissionDenied(Path)
IsDirectory(Path)
NotDirectory(Path)
AlreadyExists(Path)
OtherIoError(Str)

Path

Absolute(Array<Str>)
Relative(Array<Str>)

Effects

FileSystem

fn read_file fn(path: Path) -> Str / { FileSystem, Raise<IoError> }
fn write_file fn(path: Path, content: Str) -> () / { FileSystem, Raise<IoError> }
fn read_dir fn(path: Path) -> Array<DirEntry> / { FileSystem, Raise<IoError> }
fn exists fn(path: Path) -> Bool / { FileSystem }
fn file_type fn(path: Path) -> FileType / { FileSystem, Raise<IoError> }
fn create_dir fn(path: Path) -> () / { FileSystem, Raise<IoError> }
fn remove_file fn(path: Path) -> () / { FileSystem, Raise<IoError> }
fn remove_dir fn(path: Path) -> () / { FileSystem, Raise<IoError> }

Functions

basename

fn(path: Path) -> Option<Str>

Get the last segment of a path.

extension

fn(path: Path) -> Option<Str>

Get the file extension from the last segment.

from_string

fn(s: Str) -> Path

Parse a string into a Path. Handles both / and separators.

is_absolute

fn(path: Path) -> Bool

join

fn(base: Path, child: Path) -> Path

Join two paths. If child is Absolute, it replaces base.

normalize

fn(path: Path) -> Path

Normalize a path: resolve . and .. segments.

parent

fn(path: Path) -> Path

Get the parent path (drop last segment).

segments

fn(path: Path) -> Array<Str>

to_string

fn(path: Path) -> Str

Render a Path as a string with / separators.