ludic/ns-fs.html
2026-09-17 22:10:03 +00:00

26 lines
No EOL
4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fs — Ludic</title>
<meta name="description" content="The filesystem, wrapped into one safe, ergonomic API — no file descriptors, no byte buffers, no half-written files.">
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="docs.css">
</head>
<body>
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
<main class="wrap item">
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <span class="here">Fs</span></div>
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Fs</h1></div>
<p class="ns-blurb">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 <code>file_*</code> builtins remain underneath for streaming; <code>Fs.*</code> is the everyday layer.
Fallible calls surface failure as a value — <code>null</code>, <code>false</code>, or <code>-1</code> — that you branch on, never a crash (a first-class <code>try/else</code> 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. <a href="fs-list"><code>list</code></a> returns entries sorted, so a directory walk is reproducible across runs and platforms.
Paths are <code>/</code>-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 <a href="ns-Unicode"><code>Unicode</code></a>); use <a href="ns-Path"><code>Path</code></a> to build the paths and <a href="ns-Os"><code>Os</code></a> for per-user locations.</p>
<div class="ns-methods"><a class="ns-method" href="fs-exists.html"><code class="nm-sig">Fs.exists(p) -&gt; bool</code><span class="nm-tip">Does a path exist?</span></a><a class="ns-method" href="fs-is_dir.html"><code class="nm-sig">Fs.is_dir(p) -&gt; bool</code><span class="nm-tip">Is a path a directory?</span></a><a class="ns-method" href="fs-read_text.html"><code class="nm-sig">Fs.read_text(p) -&gt; string</code><span class="nm-tip">Read a whole file as a string.</span></a><a class="ns-method" href="fs-write_text.html"><code class="nm-sig">Fs.write_text(p, s) -&gt; bool</code><span class="nm-tip">Write a string to a file (atomically).</span></a><a class="ns-method" href="fs-append_text.html"><code class="nm-sig">Fs.append_text(p, s) -&gt; bool</code><span class="nm-tip">Append a string to a file.</span></a><a class="ns-method" href="fs-remove.html"><code class="nm-sig">Fs.remove(p) -&gt; bool</code><span class="nm-tip">Delete a file.</span></a><a class="ns-method" href="fs-size.html"><code class="nm-sig">Fs.size(p) -&gt; int</code><span class="nm-tip">File size in bytes.</span></a><a class="ns-method" href="fs-mkdir.html"><code class="nm-sig">Fs.mkdir(p) -&gt; bool</code><span class="nm-tip">Create a directory and its parents.</span></a><a class="ns-method" href="fs-copy.html"><code class="nm-sig">Fs.copy(src, dst) -&gt; bool</code><span class="nm-tip">Copy a file byte-for-byte.</span></a><a class="ns-method" href="fs-list.html"><code class="nm-sig">Fs.list(dir) -&gt; []string</code><span class="nm-tip">Directory entries, sorted.</span></a></div>
<a class="back" href="api.html">← All symbols</a>
</main>
<script src="ludic-highlight.js"></script>
<script>Ludic.installCards(); Ludic.flashTarget();</script>
</body></html>