Fs
The filesystem, wrapped into one safe, ergonomic API — no file descriptors, no byte buffers, no half-written files. The foundation for saves, config, mods, and asset loading: read and write whole files as text, check existence, make directories, copy, and list a folder. The bare file_* builtins remain underneath for streaming; Fs.* is the everyday layer.
Fallible calls surface failure as a value — null, false, or -1 — that you branch on, never a crash (a first-class try/else lands with the error-handling work). Writes are atomic (written to a temporary file and renamed into place), so a crash mid-write never corrupts the previous file. list returns entries sorted, so a directory walk is reproducible across runs and platforms.
Paths are /-separated over the native (macOS/BSD) filesystem — the fully supported target today; a sandboxed virtual filesystem for wasm and recursive directory copy are follow-ups. Text helpers are UTF-8 (they pair with Unicode); use Path to build the paths and Os for per-user locations.
Fs.exists(p) -> boolDoes a path exist?Fs.is_dir(p) -> boolIs a path a directory?Fs.read_text(p) -> stringRead a whole file as a string.Fs.write_text(p, s) -> boolWrite a string to a file (atomically).Fs.append_text(p, s) -> boolAppend a string to a file.Fs.remove(p) -> boolDelete a file.Fs.size(p) -> intFile size in bytes.Fs.mkdir(p) -> boolCreate a directory and its parents.Fs.copy(src, dst) -> boolCopy a file byte-for-byte.Fs.list(dir) -> []stringDirectory entries, sorted.