Narra

Reference

std/fs

std/fs

Files and folders: read, write, list, create and remove.

narra
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

narra
export function appendText(path: string, text: string): Result<int, string> uses io, alloc

Effects: io, alloc.

copyFile

narra
export function copyFile(from: string, to: string): Result<int, string> uses io, alloc

Effects: io, alloc.

createDir

narra
export function createDir(path: string): Result<bool, string> uses io, alloc

Effects: io, alloc.

createDirAll

narra
export function createDirAll(path: string): Result<bool, string> uses io, alloc

Effects: io, alloc.

exists

narra
export function exists(path: string): bool uses io

Effects: io.

isDir

narra
export function isDir(path: string): bool uses io

Effects: io.

listDir

narra
export function listDir(path: string): Result<Array<string>, string> uses io, alloc

Effects: io, alloc.

readBytes

narra
export function readBytes(path: string): Result<bytes, string> uses io, alloc

Effects: io, alloc.

readText

narra
export function readText(path: string): Result<string, string> uses io, alloc

Effects: io, alloc.

removeDir

narra
export function removeDir(path: string): Result<bool, string> uses io, alloc

Effects: io, alloc.

removeDirAll

narra
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

narra
export function removeFile(path: string): Result<bool, string> uses io, alloc

Effects: io, alloc.

rename

narra
export function rename(from: string, to: string): Result<bool, string> uses io, alloc

Effects: io, alloc.

writeBytes

narra
export function writeBytes(path: string, data: bytes): Result<int, string> uses io

Effects: io.

writeText

narra
export function writeText(path: string, text: string): Result<int, string> uses io

Effects: io.