FilesystemPromiseAPI

Node API: Filesystem (Promises)

The fs/promises API provides asynchronous file system methods that return promises.

The promise APIs use the underlying Node.js thread pool to perform file system operations off the event loop thread. These operations are not synchronized or threadsafe. Care must be taken when performing multiple concurrent modifications on the same file or data corruption may occur.

See also

for non-promise filesystem methods.

Inheritors

Functions

Link copied to clipboard
abstract fun access(path: Value): JsPromise<Unit>

Tests a user's permissions for the file or directory specified by path. The mode argument is an optional integer that specifies the accessibility checks to be performed. mode should be either the value fs.constants.F_OK or a mask consisting of the bitwise OR of any of fs.constants.R_OK,fs.constants.W_OK, and fs.constants.X_OK (e.g. fs.constants.W_OK | fs.constants.R_OK).

abstract fun access(path: Path, mode: AccessMode? = null): JsPromise<Unit>
abstract fun access(path: Value, mode: Value?): JsPromise<Unit>

Tests a user's permissions for the file or directory specified by path. The mode argument is an optional integer that specifies the accessibility checks to be performed. mode should be either the value fs.constants.F_OK or a mask consisting of the bitwise OR of any of fs.constants.R_OK,fs.constants.W_OK, and fs.constants.X_OK (e.g. fs.constants.W_OK | fs.constants.R_OK).

Link copied to clipboard
abstract fun readFile(path: Value): JsPromise<StringOrBuffer>
abstract fun readFile(path: Path, options: ReadFileOptions? = null): JsPromise<StringOrBuffer>
abstract fun readFile(path: Value, options: Value?): JsPromise<StringOrBuffer>

Reads the contents of a file at the specified path; provides the results or an error to the callback. This variant accepts a polyglot Value.