Reference
std/fs
std/fs
Files and folders: read, write, list, create and remove.
import * as Fs from "std/fs"
The guide teaches it in chapter 11, Files and the system.
This page is generated by scripts/std/generate.nra from narrac query --json interface std/fs. Do not edit it.
Functions
appendText
export function appendText(path: string, text: string): Result<int, string> uses io, alloc
Effects: io, alloc.
copyFile
export function copyFile(from: string, to: string): Result<int, string> uses io, alloc
Effects: io, alloc.
createDir
export function createDir(path: string): Result<bool, string> uses io, alloc
Effects: io, alloc.
createDirAll
export function createDirAll(path: string): Result<bool, string> uses io, alloc
Effects: io, alloc.
exists
export function exists(path: string): bool uses io
Effects: io.
isDir
export function isDir(path: string): bool uses io
Effects: io.
listDir
export function listDir(path: string): Result<Array<string>, string> uses io, alloc
Effects: io, alloc.
readBytes
export function readBytes(path: string): Result<bytes, string> uses io, alloc
Effects: io, alloc.
readText
export function readText(path: string): Result<string, string> uses io, alloc
Effects: io, alloc.
removeDir
export function removeDir(path: string): Result<bool, string> uses io, alloc
Effects: io, alloc.
removeDirAll
export function removeDirAll(path: string): Result<bool, string> uses io, alloc
Effects: io, alloc.
Details: removes a folder and everything in it without following links; Ok(false) when missing; refuses an empty path, a root and a path ending in . or ..; stops at the first entry it cannot remove, names it and leaves the rest; crosses mount points as rm -rf does; WASI holds one descriptor per folder level.
removeFile
export function removeFile(path: string): Result<bool, string> uses io, alloc
Effects: io, alloc.
rename
export function rename(from: string, to: string): Result<bool, string> uses io, alloc
Effects: io, alloc.
writeBytes
export function writeBytes(path: string, data: bytes): Result<int, string> uses io
Effects: io.
writeText
export function writeText(path: string, text: string): Result<int, string> uses io
Effects: io.