Synchronously 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.
Synchronously append data to a file, creating the file if it does not exist.
A path to a file. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
If a file descriptor 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 'a'
is used.
Synchronous chown(2) - Change ownership of a file.
A path to a file. If a URL is provided, it must use the file:
protocol.
Synchronous close(2) - close a file descriptor.
A file descriptor.
Synchronously 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.
Returns a new ReadStream
object.
A path to a file. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
Returns a new WriteStream
object.
A path to a file. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
Synchronously tests whether or not the given path exists by checking with the file system.
A path to a file or directory. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
Synchronous fchmod(2) - Change permissions of a file.
A file descriptor.
A file mode. If a string is passed, it is parsed as an octal integer.
Synchronous fchown(2) - Change ownership of a file.
A file descriptor.
Synchronous fdatasync(2) - synchronize a file's in-core state with storage device.
A file descriptor.
Synchronous fstat(2) - Get file status.
A file descriptor.
Synchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
A file descriptor.
Synchronous ftruncate(2) - Truncate a file to a specified length.
A file descriptor.
If not specified, defaults to 0
.
Synchronously change file timestamps of the file referenced by the supplied file descriptor.
A file descriptor.
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.
Synchronous 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.
Synchronous 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.
Change the file system timestamps of the symbolic link referenced by path
. Returns undefined
,
or throws an exception when parameters are incorrect or the operation fails.
This is the synchronous version of fs.lutimes()
.
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.
Synchronous 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
.
Synchronous 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
.
Synchronous 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
.
Synchronously 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.
Synchronously 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.
Synchronously 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.
Synchronous open(2) - open and possibly create a file, returning a file descriptor..
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
.
Synchronously reads the entire contents of a file.
A path to a file. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
If a file descriptor 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'
.
Synchronously reads the entire contents of a file.
A path to a file. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
If a file descriptor is provided, the underlying file will not be closed automatically.
Either the encoding for the result, or an object that contains the encoding and an optional flag.
If a flag is not provided, it defaults to 'r'
.
Synchronously reads the entire contents of a file.
A path to a file. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
If a file descriptor is provided, the underlying file will not be closed automatically.
Either the encoding for the result, or an object that contains the encoding and an optional flag.
If a flag is not provided, it defaults to 'r'
.
Synchronously reads data from the file referenced by the supplied file descriptor, returning the number of bytes read.
A file descriptor.
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.
Similar to the above fs.readSync
function, this version takes an optional options
object.
If no options
object is specified, it will default with the above values.
Synchronous 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.
Synchronous 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.
Synchronous 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.
Synchronous readdir(3) - read a directory.
A path to a file. If a URL is provided, it must use the file:
protocol.
If called with withFileTypes: true
the result data will be an array of Dirent.
Synchronous 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.
Synchronous 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.
Synchronous 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.
See readv
.
Synchronous 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.
Synchronous rmdir(2) - delete a directory.
A path to a file. If a URL is provided, it must use the file:
protocol.
Synchronous stat(2) - Get file status.
A path to a file. If a URL is provided, it must use the file:
protocol.
Synchronous 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.
Synchronous 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
.
Synchronous 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.
Synchronously 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.
Watch for changes on filename
, where filename
is either a file or a directory, returning an FSWatcher
.
A path to a file or directory. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
If encoding
is not supplied, the default of 'utf8'
is used.
If persistent
is not supplied, the default of true
is used.
If recursive
is not supplied, the default of false
is used.
Watch for changes on filename
, where filename
is either a file or a directory, returning an FSWatcher
.
A path to a file or directory. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
If encoding
is not supplied, the default of 'utf8'
is used.
If persistent
is not supplied, the default of true
is used.
If recursive
is not supplied, the default of false
is used.
Watch for changes on filename
, where filename
is either a file or a directory, returning an FSWatcher
.
A path to a file or directory. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
If encoding
is not supplied, the default of 'utf8'
is used.
If persistent
is not supplied, the default of true
is used.
If recursive
is not supplied, the default of false
is used.
Watch for changes on filename
, where filename
is either a file or a directory, returning an FSWatcher
.
A path to a file or directory. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
Watch for changes on filename
. The callback listener
will be called each time the file is accessed.
Watch for changes on filename
. The callback listener
will be called each time the file is accessed.
A path to a file or directory. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
Synchronously writes data to a file, replacing the file if it already exists.
A path to a file. If a URL is provided, it must use the file:
protocol.
URL support is experimental.
If a file descriptor 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.
Synchronously writes buffer
to the file referenced by the supplied file descriptor, returning the number of bytes written.
A file descriptor.
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.
Synchronously writes string
to the file referenced by the supplied file descriptor, returning the number of bytes written.
A file descriptor.
A string to write.
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.
See writev
.
Generated using TypeDoc
Valid types for path values in "fs".