File access through the fs global. Every operation has two forms: a
sync call that blocks the event loop until it completes, and an
*Async variant (readFileAsync, writeFileAsync, existsAsync,
mkdirAsync, rmAsync, readdirAsync) that returns a Promise, runs on
a dedicated 4-thread pool, and rejects with a real Error (e.g.
message === "FileNotFound").Sync calls never throw on I/O errors — a missing file or bad path
silently returns undefined. Guard with fs.exists(), or use the
*Async form when you want the error. Permission denial is separate: it
throws PermissionDenied before the operation runs.
Permissions
fs is deny-by-default.
Operations
Flag
readFile, exists, readdir (sync and async)
--allow-read
writeFile, mkdir, rm (sync and async)
--allow-write
ff script.js --allow-read=. --allow-write=./out
Relative scopes resolve against the launch cwd and stay fixed. A later
process.chdir() does not move them.
Matching is component-exact: --allow-read=/srv/app covers
/srv/app/data.json, not /srv/app2/data.json.
Symlinks are resolved before matching. The target must be inside a scope; a
symlink inside an allowed directory that points outside is denied. Writes
through a dangling symlink are denied.
.. traversal, NUL bytes, and paths at or beyond 4096 bytes are denied.
Bare --allow-read / --allow-write grant every path.
Returns the file content as a string (default or "utf8"), or as an ArrayBuffer
when "buffer" or "binary" is passed as the second argument. Returns undefined
when the I/O fails (missing file, OS permission). Reads cap at 10MB. Without
--allow-read on the path, the call throws PermissionDenied instead.
Creates the file when missing, overwrites when present. Parent directories must exist — use mkdir first. Needs --allow-write on the file.writeFile and writeFileAsync take string data (UTF-8 text); non-string values such as Uint8Array or ArrayBuffer are coerced via String() rather than written as raw bytes.Writes are capped at 10 MB. Passing data larger than 10 MB throws an error immediately (fs.writeFile: data exceeds the 10 MiB limit (nothing written)) instead of silently truncating the file.
Check existence
if (fs.exists("out.txt")) { console.log("found");}
Returns true or false. It never throws on a missing path, but a path
outside --allow-read throws PermissionDenied — a missing file inside the
scope returns false.
Make directories
fs.mkdir("a/b", true);
The second argument is recursive. Pass true to create parents as needed, omit it for a single level. Needs --allow-write on the target path.
Remove files and directories
fs.rm("out.txt");fs.rm("a", true);
The second argument is recursive. Pass true to delete a directory tree, omit it for a single file. Needs --allow-write on the target path.
List a directory
console.log(fs.readdir("."));
Returns an array of names (files and directories), or undefined when
the path is missing. Needs --allow-read on the directory.
Async variants
Same names with an Async suffix, each returning a Promise:
Inside an async function that synchronous throw becomes a rejected promise.
The flag and scope rules are identical to the sync calls.The second argument of readFileAsync is a mode: "buffer" / "binary"
returns bytes; anything else returns a string.
Known issue: after a successfulfs.*Async call the process may
never exit — the promise settles and prints, then the loop waits on the
fs pending counter forever. Failures exit normally. This is invisible
inside servers; in short scripts prefer sync calls or process.exit().
Full example
fs.writeFile("out.txt", "Hello from Fairyfly!");console.log(fs.exists("out.txt"));console.log(fs.readFile("out.txt"));fs.mkdir("a/b", true);console.log(fs.readdir("."));fs.rm("out.txt");
ff example.js --allow-read=. --allow-write=.
Limits you will hit
Max path 4096 bytes.
Max read 10MB per call.
Max write 10MB per call — throws/rejects immediately above 10MB instead of truncating.
Sync I/O failures return undefined — no exception is raised, so a
try/catch around a missing file catches nothing. Permission denial and write overflow are exceptions and do throw.
Scope roots are fixed at launch; process.chdir() does not move them.
No file watching — poll with timers instead.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"fairyfly","description":"Documentation for Fairyfly, a serverless-first backend JavaScript runtime built with Zig and powered by QuickJS.","colors":{"primary":"#5f7542","light":"#a9be86","dark":"#4c5f34"},"logo":{"light":"https://mintcdn.com/fairyfly/lKP-5nOUrOLv7Po8/logo-light.svg?fit=max\u0026auto=format\u0026n=lKP-5nOUrOLv7Po8\u0026q=85\u0026s=862d0e6beb30c77db1ef81b7396f53be","dark":"https://mintcdn.com/fairyfly/lKP-5nOUrOLv7Po8/logo-dark.svg?fit=max\u0026auto=format\u0026n=lKP-5nOUrOLv7Po8\u0026q=85\u0026s=cc08030fc46bf43fb3f82a8cf19ee10a"},"favicon":"https://mintcdn.com/fairyfly/lKP-5nOUrOLv7Po8/favicon.png?fit=max\u0026auto=format\u0026n=lKP-5nOUrOLv7Po8\u0026q=85\u0026s=5c81997e3c6e9255439b8e528b5c745b","navbar":{"links":[{"icon":"star","href":"https://github.com/AbdElMajidOuhamane/ff","label":"Star on GitHub"}],"primary":{"type":"github","href":"https://github.com/AbdElMajidOuhamane/ff"}},"footer":{"socials":{"github":"https://github.com/AbdElMajidOuhamane/ff"},"links":[{"header":"Documentation","items":[{"label":"Introduction","href":"/getting-started/introduction"},{"label":"Quickstart","href":"/getting-started/quickstart"},{"label":"Permissions","href":"/concepts/permissions"},{"label":"HTTP server","href":"/guides/http-server"},{"label":"API overview","href":"/api/overview"},{"label":"CLI reference","href":"/reference/cli"},{"label":"Serverless","href":"/guides/deploy"},{"label":"Blog","href":"/blog"}]},{"header":"Guides","items":[{"label":"Fetch client","href":"/guides/fetch-client"},{"label":"WebSocket","href":"/guides/websocket"},{"label":"Workers","href":"/guides/workers"},{"label":"Packages","href":"/guides/packages"},{"label":"Deploy","href":"/guides/deploy"}]},{"header":"Reference","items":[{"label":"Limitations","href":"/reference/limitations"},{"label":"Compatibility","href":"/reference/compatibility"},{"label":"Examples","href":"/reference/examples"},{"label":"Benchmarks","href":"/blog/microvm-benchmark"}]},{"header":"Project","items":[{"label":"GitHub","href":"https://github.com/AbdElMajidOuhamane/ff"},{"label":"Releases","href":"https://github.com/AbdElMajidOuhamane/ff/releases"},{"label":"Contributing","href":"https://github.com/AbdElMajidOuhamane/ff/blob/main/CONTRIBUTING.md"},{"label":"Security","href":"https://github.com/AbdElMajidOuhamane/ff/blob/main/SECURITY.md"},{"label":"License","href":"https://github.com/AbdElMajidOuhamane/ff/blob/main/LICENSE"},{"label":"Sponsor","href":"https://github.com/sponsors/AbdElMajidOuhamane"}]}]},"seo":{"metatags":{"theme-color":"#5f7542"}},"banner":{"content":"**Serverless-first.** Built for cold starts, tight memory, and one binary. [Deploy guide →](/guides/deploy)"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"fairyfly","hasAudioNarration":false,"actualSubdomain":"fairyfly","customDomains":["fairyfly.dev","www.fairyfly.dev"],"gitSource":{"type":"github","owner":"abdelmajidouhamane","repo":"fairyfly-documentation","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":"","_id":"6af8decd9c97d4cbd7d52ffb"},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6b01804c0027a93533652fb9","clientVersion":"0.0.4271","searchFilterCounts":[{"language":"default","tag":"Guides","count":30},{"language":"default","tag":"Guide","count":23},{"language":"default","tag":"API","count":19},{"language":"default","tag":"API reference","count":19},{"language":"default","tag":"Concepts","count":10},{"language":"default","tag":"Blog","count":8},{"language":"default","tag":"Reference","count":8},{"language":"default","tag":"Getting started","count":6}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":":root{--ff-navy: #12233f;--ff-olive: #5f7542;--ff-olive-dark: #4c5f34;--ff-text-main: #12233f;--ff-text-muted: #5b6472;--ff-border: rgba(18, 35, 63, 0.12);--ff-surface-soft: rgba(95, 117, 66, 0.06)}html.dark{--ff-text-main: #f4f0e4;--ff-text-muted: #b8c0b0;--ff-olive: #a9be86;--ff-olive-dark: #8aa266;--ff-border: rgba(238, 227, 197, 0.14);--ff-surface-soft: rgba(169, 190, 134, 0.08)}img.nav-logo{height:30px!important;width:auto!important;max-width:none!important}#navbar a[href*=\"github.com\"] svg+span,#navbar a[href*=\"github.com\"]>div>div+div{display:none!important}#navbar a[href*=\"github.com\"] svg{width:1.25rem!important;height:1.25rem!important}#navbar a[href*=\"github.com\"]{padding:0.4rem!important;border-radius:0.5rem!important;transition:opacity 0.18s ease, transform 0.18s ease}#navbar a[href*=\"github.com\"]:hover{opacity:0.8;transform:translateY(-1px)}#content-area:has(.ff-hero)>header,main:has(.ff-hero) header#header,div:has(>.mdx-content .ff-hero)>header{display:none!important}@keyframes ff-fade-up{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes ff-float{0%,100%{transform:translateY(0)}50%{transform:translateY(-7px)}}.ff-hero{padding:1.5rem 0 2.5rem;margin-bottom:1.5rem;border-bottom:1px solid var(--ff-border)}.ff-hero__grid{display:grid;grid-template-columns:minmax(0, 1.45fr) minmax(220px, 0.55fr);gap:2.5rem;align-items:center;margin-bottom:1.75rem}@media (max-width: 820px){.ff-hero__grid{grid-template-columns:1fr;gap:1.5rem;text-align:center}.ff-hero__actions{justify-content:center}}.ff-hero__copy{animation:ff-fade-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both}.ff-hero__heading{margin:0 0 1rem;color:var(--ff-text-main);font-size:clamp(2rem, 3.4vw, 2.75rem);font-weight:750;line-height:1.2;letter-spacing:-0.025em}.ff-hero__brand{display:block;width:fit-content;font-size:1.35em;font-weight:850;letter-spacing:-0.04em;margin-bottom:0.25rem;background:linear-gradient(100deg, #4c5f34 0%, #8aa266 35%, #5f7542 60%, #12233f 100%);background-size:200% auto;-webkit-background-clip:text;background-clip:text;color:transparent;animation:ff-shine 6s ease-in-out infinite alternate}html.dark .ff-hero__brand{background-image:linear-gradient(100deg, #a9be86 0%, #e3edc9 35%, #8aa266 60%, #f4f0e4 100%)}@keyframes ff-shine{from{background-position:0% center}to{background-position:100% center}}@media (max-width: 820px){.ff-hero__brand{margin-inline:auto}}.ff-hero__subtitle{display:block;color:var(--ff-text-main);font-weight:650;opacity:0.88}.ff-hero__tagline{margin:0 0 1.6rem;color:var(--ff-text-muted);font-size:1.08rem;line-height:1.65;max-width:64ch}@media (max-width: 820px){.ff-hero__tagline{margin-inline:auto}}.ff-hero__actions{display:flex;flex-wrap:wrap;align-items:center;gap:0.75rem}.ff-btn{display:inline-flex;align-items:center;justify-content:center;padding:0.65rem 1.35rem;border-radius:999px;font-size:0.94rem;font-weight:600;line-height:1.2;text-decoration:none!important;border:1px solid transparent!important;transition:transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease}.ff-btn--primary{background:#5f7542!important;color:#ffffff!important}.ff-btn--primary:hover{background:#4c5f34!important;transform:translateY(-1.5px)}.ff-btn--secondary{background:var(--ff-surface-soft)!important;color:var(--ff-text-main)!important;border-color:var(--ff-border)!important}.ff-btn--secondary:hover{border-color:var(--ff-olive)!important;transform:translateY(-1.5px)}.ff-hero__visual{display:flex;justify-content:center;align-items:center;animation:ff-fade-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.08s both}.ff-hero__img{width:100%;max-width:280px;height:auto;aspect-ratio:1 / 1;object-fit:contain;margin:0!important;animation:ff-float 6s ease-in-out infinite}.ff-hero__stats{display:grid;grid-template-columns:repeat(4, minmax(0, 1fr));gap:0.75rem;margin-top:1rem;padding-top:1rem;animation:ff-fade-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.14s both}@media (max-width: 640px){.ff-hero__stats{grid-template-columns:repeat(2, minmax(0, 1fr))}}.ff-stat{display:flex;align-items:baseline;gap:0.45rem;padding:0.55rem 0.85rem;border-radius:0.65rem;background:var(--ff-surface-soft);border:1px solid var(--ff-border)}.ff-stat__value{color:var(--ff-text-main);font-size:1.15rem;font-weight:750;letter-spacing:-0.02em}.ff-stat__label{color:var(--ff-text-muted);font-size:0.84rem}.ff-landing{margin:0 auto}@media (prefers-reduced-motion: reduce){.ff-hero__copy,.ff-hero__visual,.ff-hero__stats,.ff-hero__img{animation:none!important}}"}]}
{"page":{"pagePath":"api/fs","slug":"/api/fs","pageMetadata":{"title":"Filesystem","sidebarTitle":"fs","description":"File access — sync calls and *Async Promise variants: read, write, exists, mkdir, rm, readdir.","href":"/api/fs"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"File access — sync calls and *Async Promise variants: read, write, exists, mkdir, rm, readdir.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,em:`em`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`File access through the `,_jsx(_components.code,{children:`fs`}),` global. Every operation has two forms: a\n`,_jsx(_components.strong,{children:`sync`}),` call that blocks the event loop until it completes, and an\n`,_jsx(_components.code,{children:`*Async`}),` variant (`,_jsx(_components.code,{children:`readFileAsync`}),`, `,_jsx(_components.code,{children:`writeFileAsync`}),`, `,_jsx(_components.code,{children:`existsAsync`}),`,\n`,_jsx(_components.code,{children:`mkdirAsync`}),`, `,_jsx(_components.code,{children:`rmAsync`}),`, `,_jsx(_components.code,{children:`readdirAsync`}),`) that returns a Promise, runs on\na dedicated 4-thread pool, and `,_jsxs(_components.strong,{children:[`rejects with a real `,_jsx(_components.code,{children:`Error`})]}),` (e.g.\n`,_jsx(_components.code,{children:`message === \"FileNotFound\"`}),`).`]}),`\n`,_jsxs(_components.p,{children:[`Sync calls `,_jsx(_components.strong,{children:`never throw on I/O errors`}),` — a missing file or bad path\nsilently returns `,_jsx(_components.code,{children:`undefined`}),`. Guard with `,_jsx(_components.code,{children:`fs.exists()`}),`, or use the\n`,_jsx(_components.code,{children:`*Async`}),` form when you want the error. Permission denial is separate: it\nthrows `,_jsx(_components.code,{children:`PermissionDenied`}),` before the operation runs.`]}),`\n`,_jsx(Heading,{level:`2`,id:`permissions`,children:`Permissions`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`fs`}),` is deny-by-default.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Operations`}),_jsx(_components.th,{children:`Flag`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`readFile`}),`, `,_jsx(_components.code,{children:`exists`}),`, `,_jsx(_components.code,{children:`readdir`}),` (sync and async)`]}),_jsx(_components.td,{children:_jsx(_components.code,{children:`--allow-read`})})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[_jsx(_components.code,{children:`writeFile`}),`, `,_jsx(_components.code,{children:`mkdir`}),`, `,_jsx(_components.code,{children:`rm`}),` (sync and async)`]}),_jsx(_components.td,{children:_jsx(_components.code,{children:`--allow-write`})})]})]})]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`ff`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` script.js`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --allow-read=.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --allow-write=./out`})]}),`\n`]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Relative scopes resolve against the `,_jsx(_components.strong,{children:`launch`}),` cwd and stay fixed. A later\n`,_jsx(_components.code,{children:`process.chdir()`}),` does not move them.`]}),`\n`,_jsxs(_components.li,{children:[`Matching is component-exact: `,_jsx(_components.code,{children:`--allow-read=/srv/app`}),` covers\n`,_jsx(_components.code,{children:`/srv/app/data.json`}),`, not `,_jsx(_components.code,{children:`/srv/app2/data.json`}),`.`]}),`\n`,_jsx(_components.li,{children:`Symlinks are resolved before matching. The target must be inside a scope; a\nsymlink inside an allowed directory that points outside is denied. Writes\nthrough a dangling symlink are denied.`}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`..`}),` traversal, NUL bytes, and paths at or beyond 4096 bytes are denied.`]}),`\n`,_jsxs(_components.li,{children:[`Bare `,_jsx(_components.code,{children:`--allow-read`}),` / `,_jsx(_components.code,{children:`--allow-write`}),` grant every path.`]}),`\n`,_jsx(_components.li,{children:`There are no globs or per-extension rules.`}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Full model: `,_jsx(_components.a,{href:`/concepts/permissions`,children:`Permissions`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`read-a-file`,children:`Read a file`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` text`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`readFile`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"notes.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// string (default)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` bytes`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`readFile`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"image.png\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"buffer\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// ArrayBuffer`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Returns the file content as a string (default or `,_jsx(_components.code,{children:`\"utf8\"`}),`), or as an `,_jsx(_components.code,{children:`ArrayBuffer`}),`\nwhen `,_jsx(_components.code,{children:`\"buffer\"`}),` or `,_jsx(_components.code,{children:`\"binary\"`}),` is passed as the second argument. Returns `,_jsx(_components.code,{children:`undefined`}),`\nwhen the `,_jsx(_components.strong,{children:`I/O`}),` fails (missing file, OS permission). Reads cap at 10MB. Without\n`,_jsx(_components.code,{children:`--allow-read`}),` on the path, the call throws `,_jsx(_components.code,{children:`PermissionDenied`}),` instead.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`ff`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` read.js`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --allow-read=notes.txt`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# or: --allow-read=.`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`write-a-file`,children:`Write a file`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`writeFile`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"out.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Hello from Fairyfly!\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Creates the file when missing, overwrites when present. Parent directories must exist — use `,_jsx(_components.code,{children:`mkdir`}),` first. Needs `,_jsx(_components.code,{children:`--allow-write`}),` on the file.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`writeFile`}),` and `,_jsx(_components.code,{children:`writeFileAsync`}),` take string data (UTF-8 text); non-string values such as `,_jsx(_components.code,{children:`Uint8Array`}),` or `,_jsx(_components.code,{children:`ArrayBuffer`}),` are coerced via `,_jsx(_components.code,{children:`String()`}),` rather than written as raw bytes.`]}),`\n`,_jsxs(_components.p,{children:[`Writes are capped at `,_jsx(_components.strong,{children:`10 MB`}),`. Passing data larger than 10 MB throws an error immediately (`,_jsx(_components.code,{children:`fs.writeFile: data exceeds the 10 MiB limit (nothing written)`}),`) instead of silently truncating the file.`]}),`\n`,_jsx(Heading,{level:`2`,id:`check-existence`,children:`Check existence`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`exists`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"out.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"found\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Returns `,_jsx(_components.code,{children:`true`}),` or `,_jsx(_components.code,{children:`false`}),`. It never throws on a missing path, but a path\noutside `,_jsx(_components.code,{children:`--allow-read`}),` throws `,_jsx(_components.code,{children:`PermissionDenied`}),` — a missing file inside the\nscope returns `,_jsx(_components.code,{children:`false`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`make-directories`,children:`Make directories`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`mkdir`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"a/b\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The second argument is `,_jsx(_components.code,{children:`recursive`}),`. Pass `,_jsx(_components.code,{children:`true`}),` to create parents as needed, omit it for a single level. Needs `,_jsx(_components.code,{children:`--allow-write`}),` on the target path.`]}),`\n`,_jsx(Heading,{level:`2`,id:`remove-files-and-directories`,children:`Remove files and directories`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rm`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"out.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rm`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"a\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The second argument is `,_jsx(_components.code,{children:`recursive`}),`. Pass `,_jsx(_components.code,{children:`true`}),` to delete a directory tree, omit it for a single file. Needs `,_jsx(_components.code,{children:`--allow-write`}),` on the target path.`]}),`\n`,_jsx(Heading,{level:`2`,id:`list-a-directory`,children:`List a directory`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`readdir`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\".\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`));`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Returns an array of names (files and directories), or `,_jsx(_components.code,{children:`undefined`}),` when\nthe path is missing. Needs `,_jsx(_components.code,{children:`--allow-read`}),` on the directory.`]}),`\n`,_jsx(Heading,{level:`2`,id:`async-variants`,children:`Async variants`}),`\n`,_jsxs(_components.p,{children:[`Same names with an `,_jsx(_components.code,{children:`Async`}),` suffix, each returning a Promise:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` text`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`readFileAsync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"notes.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// string (default)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` bytes`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`readFileAsync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"data.bin\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"buffer\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// ArrayBuffer`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` ok`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`existsAsync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"notes.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// boolean`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`writeFileAsync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"out.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"hello\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`mkdirAsync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"a/b\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rmAsync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"out.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` names`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`readdirAsync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\".\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Failures `,_jsx(_components.strong,{children:`reject`}),` instead of being swallowed (including `,_jsx(_components.code,{children:`writeFileAsync`}),` with data > 10 MB):`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`readFileAsync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"missing.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`} `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`catch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`e`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`e`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// \"FileNotFound\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Permission denial is thrown `,_jsx(_components.strong,{children:`synchronously`}),`, before the Promise is created:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` p`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`readFileAsync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"/etc/passwd\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// throws here`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`} `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`catch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`e`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`e`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`name`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`e`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`code`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// \"PermissionDenied\" \"PERMISSION_DENIED\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Inside an `,_jsx(_components.code,{children:`async`}),` function that synchronous throw becomes a rejected promise.\nThe flag and scope rules are identical to the sync calls.`]}),`\n`,_jsxs(_components.p,{children:[`The second argument of `,_jsx(_components.code,{children:`readFileAsync`}),` is a mode: `,_jsx(_components.code,{children:`\"buffer\"`}),` / `,_jsx(_components.code,{children:`\"binary\"`}),`\nreturns bytes; anything else returns a string.`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Known issue:`}),` after a `,_jsx(_components.em,{children:`successful`}),` `,_jsx(_components.code,{children:`fs.*Async`}),` call the process may\nnever exit — the promise settles and prints, then the loop waits on the\nfs pending counter forever. Failures exit normally. This is invisible\ninside servers; in short scripts prefer sync calls or `,_jsx(_components.code,{children:`process.exit()`}),`.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`full-example`,children:`Full example`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`writeFile`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"out.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Hello from Fairyfly!\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`exists`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"out.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`));`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`readFile`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"out.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`));`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`mkdir`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"a/b\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`readdir`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\".\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`));`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`rm`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"out.txt\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`ff`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` example.js`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --allow-read=.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --allow-write=.`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`limits-you-will-hit`,children:`Limits you will hit`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Max path 4096 bytes.`}),`\n`,_jsx(_components.li,{children:`Max read 10MB per call.`}),`\n`,_jsx(_components.li,{children:`Max write 10MB per call — throws/rejects immediately above 10MB instead of truncating.`}),`\n`,_jsxs(_components.li,{children:[`Sync `,_jsx(_components.strong,{children:`I/O`}),` failures return `,_jsx(_components.code,{children:`undefined`}),` — no exception is raised, so a\n`,_jsx(_components.code,{children:`try/catch`}),` around a missing file catches nothing. Permission denial and write overflow are exceptions and do throw.`]}),`\n`,_jsxs(_components.li,{children:[`Scope roots are fixed at launch; `,_jsx(_components.code,{children:`process.chdir()`}),` does not move them.`]}),`\n`,_jsx(_components.li,{children:`No file watching — poll with timers instead.`}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Filesystem","sidebarTitle":"fs","description":"File access — sync calls and *Async Promise variants: read, write, exists, mkdir, rm, readdir.","href":"/api/fs"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Permissions","slug":"permissions","depth":2,"children":[]},{"title":"Read a file","slug":"read-a-file","depth":2,"children":[]},{"title":"Write a file","slug":"write-a-file","depth":2,"children":[]},{"title":"Check existence","slug":"check-existence","depth":2,"children":[]},{"title":"Make directories","slug":"make-directories","depth":2,"children":[]},{"title":"Remove files and directories","slug":"remove-files-and-directories","depth":2,"children":[]},{"title":"List a directory","slug":"list-a-directory","depth":2,"children":[]},{"title":"Async variants","slug":"async-variants","depth":2,"children":[]},{"title":"Full example","slug":"full-example","depth":2,"children":[]},{"title":"Limits you will hit","slug":"limits-you-will-hit","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"fairyfly","siteName":"fairyfly","title":"Filesystem - fairyfly","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-15T11:25:31.661Z","originalFileLocation":"api/fs.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"File access — sync calls and *Async Promise variants: read, write, exists, mkdir, rm, readdir.\">\u003cmeta data-mint-head name=\"application-name\" content=\"fairyfly\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/fairyfly/Q7TYtoBa5NDzy9WU/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/fairyfly/Q7TYtoBa5NDzy9WU/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/fairyfly/Q7TYtoBa5NDzy9WU/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/fairyfly/Q7TYtoBa5NDzy9WU/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/fairyfly/Q7TYtoBa5NDzy9WU/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/fairyfly/Q7TYtoBa5NDzy9WU/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/fairyfly/Q7TYtoBa5NDzy9WU/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/fairyfly/Q7TYtoBa5NDzy9WU/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/fairyfly/Q7TYtoBa5NDzy9WU/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Filesystem - fairyfly\">\u003cmeta data-mint-head property=\"og:description\" content=\"File access — sync calls and *Async Promise variants: read, write, exists, mkdir, rm, readdir.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"fairyfly\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://fairyfly.dev/api/fs\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://fairyfly.mintlify.site/_mintlify/api/og/v2?division=API+reference\u0026amp;title=Filesystem\u0026amp;description=File+access+%E2%80%94+sync+calls+and+*Async+Promise+variants%3A+read%2C+write%2C+exists%2C+mkdir%2C+rm%2C+readdir.\u0026amp;theme=41d35be07febaba2b71bca05\u0026amp;signature=93963507733931139a823e06d3d77b7bd4cb4a34d624a885e77dc3480b27615b\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Filesystem - fairyfly\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"File access — sync calls and *Async Promise variants: read, write, exists, mkdir, rm, readdir.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://fairyfly.mintlify.site/_mintlify/api/og/v2?division=API+reference\u0026amp;title=Filesystem\u0026amp;description=File+access+%E2%80%94+sync+calls+and+*Async+Promise+variants%3A+read%2C+write%2C+exists%2C+mkdir%2C+rm%2C+readdir.\u0026amp;theme=41d35be07febaba2b71bca05\u0026amp;signature=93963507733931139a823e06d3d77b7bd4cb4a34d624a885e77dc3480b27615b\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/fairyfly/Q7TYtoBa5NDzy9WU/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"fairyfly\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#5f7542\">\u003cmeta data-mint-head name=\"theme-color\" content=\"#5f7542\">\u003clink data-mint-head rel=\"canonical\" href=\"https://fairyfly.dev/api/fs\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api/fs.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://fairyfly.dev/#organization\",\"name\":\"fairyfly\",\"url\":\"https://fairyfly.dev\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/fairyfly/lKP-5nOUrOLv7Po8/logo-light.svg?fit=max\u0026auto=format\u0026n=lKP-5nOUrOLv7Po8\u0026q=85\u0026s=862d0e6beb30c77db1ef81b7396f53be\"}},{\"@type\":\"WebSite\",\"@id\":\"https://fairyfly.dev#website\",\"name\":\"fairyfly\",\"url\":\"https://fairyfly.dev\",\"publisher\":{\"@id\":\"https://fairyfly.dev/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://fairyfly.dev/api/fs#webpage\",\"url\":\"https://fairyfly.dev/api/fs\",\"name\":\"Filesystem\",\"description\":\"File access — sync calls and *Async Promise variants: read, write, exists, mkdir, rm, readdir.\",\"dateModified\":\"2026-11-15T11:25:31.661Z\",\"isPartOf\":{\"@id\":\"https://fairyfly.dev#website\"},\"breadcrumb\":{\"@id\":\"https://fairyfly.dev/api/fs#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://fairyfly.dev/api/fs#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"API reference\",\"item\":\"https://fairyfly.dev/api/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Filesystem\",\"item\":\"https://fairyfly.dev/api/fs\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://fairyfly.dev/api/fs#article\",\"headline\":\"Filesystem\",\"name\":\"Filesystem\",\"description\":\"File access — sync calls and *Async Promise variants: read, write, exists, mkdir, rm, readdir.\",\"url\":\"https://fairyfly.dev/api/fs\",\"mainEntityOfPage\":{\"@id\":\"https://fairyfly.dev/api/fs#webpage\"},\"dateModified\":\"2026-11-15T11:25:31.661Z\",\"publisher\":{\"@id\":\"https://fairyfly.dev/#organization\"},\"isPartOf\":{\"@id\":\"https://fairyfly.dev#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"fairyfly\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"fairyfly\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/api/fs.md","siteName":"fairyfly","nav":{"global":null,"tabs":[{"tab":"Home","hidden":true,"pages":[{"title":"Home","href":""}]},{"tab":"Guide","menu":[{"item":"Getting started","pages":[{"title":"Getting started","href":"/getting-started/introduction"}]},{"item":"Concepts","pages":[{"title":"Concepts","href":"/concepts/event-loop"}]},{"item":"Guides","pages":[{"title":"Guides","href":"/guides/http-server"}]},{"item":"Serverless","href":"/guides/deploy"}],"pages":[{"title":"Guide","href":"/getting-started/introduction"}]},{"tab":"API","groups":[{"group":"API reference","pages":[{"title":"API overview","sidebarTitle":"Overview","href":"/api/overview"},{"title":"http API","sidebarTitle":"http","href":"/api/http"},{"title":"fetch API","sidebarTitle":"fetch","href":"/api/fetch"},{"title":"Request / Response / Headers","href":"/api/request-response"},{"title":"WebSocket","href":"/api/websocket"},{"title":"udp API","sidebarTitle":"udp","description":"udp.socket reference — POSIX-style datagram sockets: bind, sendto, recvfrom, and connected send/recv.","href":"/api/udp"},{"title":"Filesystem","sidebarTitle":"fs","href":"/api/fs"},{"title":"console","description":"Output, colored aliases, and time/timeLog/timeEnd — every method and its quirks.","href":"/api/console"},{"title":"Process","sidebarTitle":"process","href":"/api/process"},{"title":"child_process","href":"/api/child-process"},{"title":"URL","href":"/api/url"},{"title":"crypto","href":"/api/crypto"},{"title":"Text encoding","href":"/api/text-encoding"},{"title":"performance","href":"/api/performance"},{"title":"Worker","href":"/api/worker"},{"title":"Blob and FormData","href":"/api/blobs-formdata"},{"title":"SQLite API","sidebarTitle":"SQLite","href":"/api/sqlite"},{"title":"PostgreSQL API","sidebarTitle":"Postgres","href":"/api/postgres"},{"title":"FFI (ffi global)","sidebarTitle":"FFI","href":"/api/ffi"}]}]},{"tab":"Reference","pages":[{"title":"Reference","href":"/reference/cli"}]},{"tab":"Blog","pages":[{"title":"Blog","href":"/blog"}]}]},"basePath":"","title":"Filesystem - fairyfly","deploymentId":"dpl_Em2U4NQQ2N2DE3HPbPUJVZLnAtvc","buildId":"dpl_Em2U4NQQ2N2DE3HPbPUJVZLnAtvc","dynamics":["10e4515597"],"chunks":["BannerMarkdown-CVKwuln2.js","dist-CXMB3QQU.js","lib-DMeTj1gb.js","lib-B8HbPgcC.js","katex-Dbtb6Wk7.js","html-void-elements-mCSPHezU.js","marked.esm-CZWythHk.js"]}