Skip to main content
Version: Next

RsvimFs

The Rsvim.fs global object for file system and file IO.

Example

// Create a alias to 'Rsvim.fs'.
const fs = Rsvim.fs;

Classes

ClassDescription

File

The File object that access to an open file on filesystem.

See

RsvimFs.open

Type Aliases

Type AliasDescription

OpenOptions

Open options.

tip

It is same with std::fs::OpenOptions in rust std library.

See

RsvimFs.open

Functions

FunctionDescription

open

Open a file and resolve to an instance of RsvimFs.File. The file does not need to previously exist if using the create or createNew open options. The caller have to close the file to prevent resource leaking, see RsvimFs.File.close.

Throws

Throws TypeError if any parameters are invalid. Or throws Error if failed to open/create the file.

Example

const file = await Rsvim.fs.open("README.md");

openSync

The sync version of open.

Throws

Example

const file = Rsvim.fs.openSync("README.md");

readFile

Read a file in binary mode, i.e. into an array of bytes buffer, without open/close a file descriptor/handle.

Throws

Throws TypeError if the file name is invalid. Or throws Error if failed to read the file.

Example

const buffer = await Rsvim.fs.readFile("README.md");

readFileSync

The sync version of readFile.

Throws

Example

const buffer = Rsvim.fs.readFileSync("README.md");

readTextFile

Read a file in text mode, i.e. into a string, without open/close a file descriptor/handle.

Throws

Throws TypeError if the file name is invalid. Or throws Error if failed to read the file.

Example

const payload = await Rsvim.fs.readTextFile("README.md");

readTextFileSync

The sync version of readTextFile.

Throws

Example

const payload = Rsvim.fs.readTextFileSync("README.md");