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;

Methods

open()

open(path, options?): Promise<File>;

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.

Parameters

ParameterTypeDescription

path

string

File path.

options?

OpenOptions

(Optional) Open options, by default is {read: true}. See RsvimFs.OpenOptions.

Returns

Promise<File>

It resolves to an instance of RsvimFs.File.

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()

openSync(path, options?): File;

The sync version of open.

Parameters

ParameterTypeDescription

path

string

Same with open.

options?

OpenOptions

Same with open.

Returns

File

It returns a RsvimFs.File.

Throws

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

Example

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