[fs.promises] Asynchronously tests a user's permissions for the file specified by path.
A path to a file or directory. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
[fs.promises] Asynchronously append data to a file, creating the file if it does not exist.
The data to write. If something other than a Buffer
or Uint8Array
is provided, the value is coerced to a string.
Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
If encoding
is not supplied, the default of 'utf8'
is used.
If mode
is not supplied, the default of 0o666
is used.
If mode
is a string, it is parsed as an octal integer.
If flag
is not supplied, the default of 'a'
is used.
[fs.promises] Asynchronous chmod(2) - Change permissions of a file.
A path to a file. If a URL is provided, it must use the file:
protocol.
A file mode. If a string is passed, it is parsed as an octal integer.
[fs.promises] Asynchronous chown(2) - Change ownership of a file.
A path to a file. If a URL is provided, it must use the file:
protocol.
Copies files from one location to another, creating all directories required to satisfy the destination path. source and destination paths.
The source path
The destination path
Options for the copy, or a filter function
[fs.promises] Asynchronously copies src
to dest
. By default, dest
is overwritten if it already exists.
Node.js makes no guarantees about the atomicity of the copy operation.
If an error occurs after the destination file has been opened for writing, Node.js will attempt
to remove the destination.
A path to the source file.
A path to the destination file.
An optional integer that specifies the behavior of the copy operation. The only
supported flag is fs.constants.COPYFILE_EXCL
, which causes the copy operation to fail if
dest
already exists.
The path to the file you want to copy
The path to the file destination
Creates an empty file, making all folders required to satisfy the given file path.
Path of the file you want to create
Whether the operation should run atomically
Creates an file copy, making all folders required to satisfy the given file path atomically.
Path of the file you want to create
Creates an file copy, making all folders required to satisfy the given file path.
The path to the file you want to copy
The path to the file destination
Whether the operation should run atomically
Creates a file copy atomically, making all folders required to satisfy the given file path.
The path to the file you want to copy
The path to the file destination
Creates a hard file link, making all folders required to satisfy the given file path.
The source path of the file
The destination path of the file
Whether the operation should run atomically
Creates a hard file link, making all folders required to satisfy the given file path atomically.
The source path of the file
The destination path of the file
Creates a soft file link, making all folders required to satisfy the given file path.
The source path of the file
The destination path of the file
Whether the operation should run atomically
Creates a soft file link, making all folders required to satisfy the given file path atomically.
The source path of the file
The destination path of the file
The type of symlink you are creating
Deletes all directories and files within the provided directory.
The directory you wish to empty
[fs.promises] Asynchronous fchmod(2) - Change permissions of a file.
A FileHandle
.
A file mode. If a string is passed, it is parsed as an octal integer.
[fs.promises] Asynchronous fchown(2) - Change ownership of a file.
A FileHandle
.
Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
A FileHandle
.
[fs.promises] Asynchronous fstat(2) - Get file status.
A FileHandle
.
[fs.promises] Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
A FileHandle
.
[fs.promises] Asynchronous ftruncate(2) - Truncate a file to a specified length.
A FileHandle
.
If not specified, defaults to 0
.
[fs.promises] Asynchronously change file timestamps of the file referenced by the supplied FileHandle
.
A FileHandle
.
The last access time. If a string is provided, it will be coerced to number.
The last modified time. If a string is provided, it will be coerced to number.
Un-Gzips a file
The filename of the archive
The filepath of the input file
If the gzip file should be created
Un-Gzips a file atomically.
The filename of the archive
The filepath of the input file
[fs.promises] Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
A path to a file. If a URL is provided, it must use the file:
protocol.
A file mode. If a string is passed, it is parsed as an octal integer.
[fs.promises] Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
A path to a file. If a URL is provided, it must use the file:
protocol.
[fs.promises] Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
A path to a file. If a URL is provided, it must use the file:
protocol.
A path to a file. If a URL is provided, it must use the file:
protocol.
Creates a hard file link atomically.
The source path of the file
The destination path of the file
[fs.promises] Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
A path to a file. If a URL is provided, it must use the file:
protocol.
[fs.promises] Asynchronous mkdir(2) - create a directory.
A path to a file. If a URL is provided, it must use the file:
protocol.
Either the file mode, or an object optionally specifying the file mode and whether parent folders
should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to 0o777
.
Recursively makes directories, until the directory passed exists.
The path you wish to make
Options for making the directories
[fs.promises] Asynchronously creates a unique temporary directory.
Generates six random characters to be appended behind a required prefix
to create a unique temporary directory.
The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8'
is used.
The source path of the file
The destination path of the file
The options for the move
[fs.promises] Asynchronous open(2) - open and possibly create a file.
A path to a file. If a URL is provided, it must use the file:
protocol.
A file mode. If a string is passed, it is parsed as an octal integer. If not
supplied, defaults to 0o666
.
Writes a file to disk, creating all directories needed to meet the filepath provided.
The path to the file you want to create
The data to write to file
Writes a file to disk, creating all directories needed to meet the filepath provided atomically.
The path to the file you want to create
The data to write to file
The write options or the encoding string.
Writes a json file to disk, creating all directories needed to meet the filepath provided.
The path to the file you want to create
The data to write to file
If the operation should be done atomically
Writes a json file to disk, creating all directories needed to meet the filepath provided atomically.
The path to the file you want to create
The data to write to file
The write options or the encoding string.
Checks if a path exists.
The path to check
[fs.promises] Asynchronously reads data from the file referenced by the supplied FileHandle
.
A FileHandle
.
The buffer that the data will be written to.
The offset in the buffer at which to start writing.
The number of bytes to read.
The offset from the beginning of the file from which data should be read. If
null
, data will be read from the current position.
[fs.promises] Asynchronously reads the entire contents of a file.
A path to a file. If a URL is provided, it must use the file:
protocol.
If a FileHandle
is provided, the underlying file will not be closed automatically.
An object that may contain an optional flag.
If a flag is not provided, it defaults to 'r'
.
Reads a file and parses it into a javascript object.
The file path to the json file
[fs.promises] Asynchronous readdir(3) - read a directory.
A path to a file. If a URL is provided, it must use the file:
protocol.
The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8'
is used.
[fs.promises] Asynchronous readlink(2) - read value of a symbolic link.
A path to a file. If a URL is provided, it must use the file:
protocol.
The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8'
is used.
[fs.promises] Asynchronous realpath(3) - return the canonicalized absolute pathname.
A path to a file. If a URL is provided, it must use the file:
protocol.
The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8'
is used.
Removes a single file or single directory with no children.
The path to remove
The remove options
[fs.promises] Asynchronous rename(2) - Change the name or location of a file or directory.
A path to a file. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
A path to a file. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
[fs.promises] Asynchronous rmdir(2) - delete a directory.
A path to a file. If a URL is provided, it must use the file:
protocol.
Recursively scans a directory, returning a map of stats keyed on the full path to the item.
The path to scan
The options for the scan
[fs.promises] Asynchronous stat(2) - Get file status.
A path to a file. If a URL is provided, it must use the file:
protocol.
[fs.promises] Asynchronous symlink(2) - Create a new symbolic link to an existing file.
A path to an existing file. If a URL is provided, it must use the file:
protocol.
A path to the new symlink. If a URL is provided, it must use the file:
protocol.
May be set to 'dir'
, 'file'
, or 'junction'
(default is 'file'
) and is only available on Windows (ignored on other platforms).
When using 'junction'
, the target
argument will automatically be normalized to an absolute path.
Creates a soft file link atomically.
The source path of the file
The destination path of the file
The type of symlink you are creating
Tar/Gzips a directory or array of files.
The filename of the archive
The directory or array of filepaths to .tar.gz
Tar/Gzips a directory or array of files.
The filename of the archive
The directory or array of filepaths to .tar.gz
[fs.promises] Asynchronous truncate(2) - Truncate a file to a specified length.
A path to a file. If a URL is provided, it must use the file:
protocol.
If not specified, defaults to 0
.
Extracts files from .tar.gz archives.
The directory to extract to
The archive file
The if the writes should be atomic
Extracts files from .tar.gz archives and writes them atomically.
The directory to extract to
The archive file
[fs.promises] Asynchronous unlink(2) - delete a name and possibly the file it refers to.
A path to a file. If a URL is provided, it must use the file:
protocol.
[fs.promises] Asynchronously change file timestamps of the file referenced by the supplied path.
A path to a file. If a URL is provided, it must use the file:
protocol.
The last access time. If a string is provided, it will be coerced to number.
The last modified time. If a string is provided, it will be coerced to number.
[fs.promises] Asynchronously writes buffer
to the file referenced by the supplied FileHandle
.
It is unsafe to call fsPromises.write()
multiple times on the same file without waiting for the Promise
to be resolved (or rejected). For this scenario, fs.createWriteStream
is strongly recommended.
A FileHandle
.
The buffer that the data will be written to.
The part of the buffer to be written. If not supplied, defaults to 0
.
The number of bytes to write. If not supplied, defaults to buffer.length - offset
.
The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
[fs.promises] Asynchronously writes string
to the file referenced by the supplied FileHandle
.
It is unsafe to call fsPromises.write()
multiple times on the same file without waiting for the Promise
to be resolved (or rejected). For this scenario, fs.createWriteStream
is strongly recommended.
A FileHandle
.
A string to write. If something other than a string is supplied it will be coerced to a string.
The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
The expected string encoding.
[fs.promises] Asynchronously writes data to a file, replacing the file if it already exists.
It is unsafe to call fsPromises.writeFile()
multiple times on the same file without waiting for the Promise
to be resolved (or rejected).
A path to a file. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
If a FileHandle
is provided, the underlying file will not be closed automatically.
The data to write. If something other than a Buffer
or Uint8Array
is provided, the value is coerced to a string.
Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
If encoding
is not supplied, the default of 'utf8'
is used.
If mode
is not supplied, the default of 0o666
is used.
If mode
is a string, it is parsed as an octal integer.
If flag
is not supplied, the default of 'w'
is used.
The path to the file you want to create
The data to write to file
The write options or the encoding string.
Writes a Javascript Object to file as JSON.
The path to the file you want to create
The javascript object you would like to write to file
Writes a Javascript Object to file as JSON atomically.
The path to the file you want to create
The javascript object you would like to write to file
The options to pass JSON.stringify and writeFile
Generated using TypeDoc
The type of symlink you are creating:
dir
file
junction
{string} SymLinkType
fsn/nextra