Class: FS

FS()

new FS()

Initialize a new FS object.
Source:

Methods

(async) mkdir(path)

Make a directory in the filesystem.
Parameters:
Name Type Description
path String the path to the directory.
Source:
Throws:
if the directory cannot be created.
Type
Error

(async) mountIdbfs(path)

Mount a directory as the IDBFS filesystem (persistent storage).
Parameters:
Name Type Description
path String the path to the directory.
Source:
Throws:
if the directory cannot be mounted.
Type
Error

(async) readDir(path) → {Array}

Get the files in a directory.
Parameters:
Name Type Description
path String the path to the directory.
Source:
Throws:
if the files cannot be retrieved.
Type
Error
Returns:
the files in the directory.
Type
Array

(async) readFile(path) → {Buffer}

Read a file from the filesystem.
Parameters:
Name Type Description
path String the path to the file.
Source:
Throws:
if the file cannot be read.
Type
Error
Returns:
the file contents.
Type
Buffer

(async) rename(oldPath, newPath)

Rename a file in the filesystem.
Parameters:
Name Type Description
oldPath String the old path to the file.
newPath String the new path to the file.
Source:
Throws:
if the file cannot be renamed.
Type
Error

(async) rmdir(path)

Remove a directory from the filesystem.
Parameters:
Name Type Description
path String the path to the directory.
Source:
Throws:
if the directory cannot be removed.
Type
Error

(async) stat(path) → {Object}

Get the status of a file in the filesystem.
Parameters:
Name Type Description
path String the path to the file.
Source:
Throws:
if the status cannot be retrieved.
Type
Error
Returns:
the status of the file.
Type
Object

(async) syncfs(populate)

Synchronize the IDBFS filesystem with the underlying storage.
Parameters:
Name Type Description
populate Boolean control the intended direction of the synchronization `true` to initialize the file system data with the data from the file system’s persistent source, and `false` to save the file system data to the file system’s persistent source.
Source:
Throws:
if the filesystem cannot be synchronized.
Type
Error
Remove a file from the filesystem.
Parameters:
Name Type Description
path String the path to the file.
Source:
Throws:
if the file cannot be removed.
Type
Error

(async) unmount(path)

Unmount a mounted filesystem.
Parameters:
Name Type Description
path String the path to the filesystem.
Source:
Throws:
if the filesystem cannot be unmounted.
Type
Error

(async) writeFile(path, data)

Write a file to the filesystem.
Parameters:
Name Type Description
path String the path to the file.
data Buffer | String the data to write.
Source:
Throws:
if the file cannot be written.
Type
Error