Perry implements Node.js file system APIs for reading, writing, and managing files.
{{#include ../../examples/stdlib/fs/snippets.ts:read-text}}{{#include ../../examples/stdlib/fs/snippets.ts:read-binary}}readFileBuffer reads files as binary data (uses fs::read() internally, not read_to_string()).
{{#include ../../examples/stdlib/fs/snippets.ts:write-text}}{{#include ../../examples/stdlib/fs/snippets.ts:stat}}{{#include ../../examples/stdlib/fs/snippets.ts:dirs}}For recursive removal Perry exposes rmRecursive (a thin wrapper around
std::fs::remove_dir_all). Wired via
#193 through
js_fs_rm_recursive in the LLVM backend.
import { rmRecursive } from "fs";
rmRecursive("output"); // Recursive remove; returns 1 on success, 0 on failure.{{#include ../../examples/stdlib/fs/snippets.ts:path-utils}}For import.meta.url → filesystem path conversion, use fileURLToPath from
the url module:
import { fileURLToPath } from "url";
import { dirname } from "path";
const dir = dirname(fileURLToPath(import.meta.url));
- HTTP & Networking
- Overview — All stdlib modules