NodeFilesystemPromiseAPI

Node API: Filesystem Promises (Module)

Defines the module-level API for the Node fs/promises built-in module, which is the combination of FilesystemPromiseAPI and WritableFilesystemPromiseAPI.

See also

for read methods which produce promises.

for write methods which produce promises.

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 copyFile(src: Value, dest: Value): JsPromise<Value>
abstract fun copyFile(src: Value, dest: Value, mode: Int): JsPromise<Value>

Asynchronously copies a file.

abstract fun copyFile(src: Path, dest: Path, mode: Int? = null): JsPromise<Value>

Asynchronously copies a file using host-side types.

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

Asynchronously creates a directory.

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.

Link copied to clipboard
abstract fun writeFile(path: Value, data: Value): JsPromise<Unit>
abstract fun writeFile(path: Path, data: StringOrBuffer, options: WriteFileOptions? = null): JsPromise<Unit>
abstract fun writeFile(path: Value, data: Value, options: Value?): JsPromise<Unit>

Asynchronously writes data to a file, replacing the file if it already exists. data can be a string, a buffer, an AsyncIterable, or an Iterable object. The promise is fulfilled with no arguments upon success.