io

.zn module

Higher-level file/stream helpers over fs. import "io". Follows the (value, err) convention.

io.read_config_lines(path) => ([string], string?)

Read lines, trimmed, dropping blanks and # comments.

io.read_lines_trimmed(path) => ([string], string?)

Read lines with each trimmed.

io.write_lines(path, lines: [string]) => string?

Write one line per element (trailing newline).

io.append_line(path, line: string) => string?

Append a single line.

io.copy_file(src, dst) => string?

Copy a file, with a descriptive error on failure.

io.parse_env_file(path) => ([string, string], string?)

Parse a KEY=VALUE file into a map (skips #, re-joins =).

io.ensure_dir(path) => string?

Create a directory if it doesn't exist.

io.file_size(path) => (int, string?)

File size in bytes (-1 on error).

io.read_simple_json_string(path, key) => (string, string?)

Grab one top-level string value from a flat JSON file (not a real parser — use json for that).

On this page