This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 11/4/2026.

FS

import std/fs

Koru Standard Library: Filesystem

fs.kz · 10 tors · ~[comptime]· ~[runtime]

Koru Standard Library: Filesystem File operations with phantom types for resource safety

Phantom lifecycles

Derived from the phantom labels in the declarations below — state! issues an obligation the compiler will chase, !state discharges it, a bare state holds it without moving it. Nothing here is hand-drawn.

Dir 1 state open!

read-lines

aspirational koru_std/fs.kz:27

~part dir koru_std/fs.dir.kz

DIRECTORY CAPABILITY - *Dir<open> confines every verb to its root fs:dir(path) mints a directory handle; the sandbox IS the handle, not a path-check repeated at every call site. list/read/write/read-lines-in/ collect-lines borrow *Dir<open>; close discharges *Dir<!open>. Every `path:` arg is root-relative — absolute paths and `..` components fire `| failed` here, inside std/fs, so a caller (or a wire model) cannot escape by spelling one. collect-lines materializes the `! line` effect stream as a []string field — the shape a wire consumer sees, since wire arms cannot spell `!`. Wire payloads render it as a JSON array (FieldValue.string_array).

close

<!open> koru_std/fs.dir.kz:49

read-lines-in

<open> koru_std/fs.dir.kz:112

collect-lines

<open> koru_std/fs.dir.kz:145

~part sync koru_std/fs.sync.kz

SYNC — fsync-grade durability for a path `sync(path)` opens the path and fsyncs it: after `| synced`, the file's bytes are on the device, not in the page cache. A bare `write-file` answers survive-process-death; this answers survive-power-loss — the durability level celld's acknowledged writes carry (SQLite fsync per put).