Node.js File System Module
File system
The node:fs module enables interacting with the file system in away modeled on standard POSIX functions.
The node:fs module enables interacting with the file system in away modeled on standard POSIX functions.
The callback form takes a completion callback function as its last argument and invokes the operation asynchronously. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception.
When operating on file handles, the mode cannot be changed from what it was set to with fsPromises.open(). Therefore, this is equivalent to filehandle.writeFile().
Modifies the permissions on the file.
Changes the ownership of the file.
Closes the file handle after waiting for any pending operation on the handle to complete.
Returns: <Promise> Fulfills with undefined upon success.
options <Object>encoding <string> Default: null
autoClose <boolean> Default: true
emitClose <boolean> Default: true
options <Object>encoding <string> Default: 'utf8'
autoClose <boolean> Default: true
emitClose <boolean> Default: true
Forces all currently queued I/O operations associated with the file to theoperating system's synchronized I/O completion state. Refer to the POSIXfdatasync(2) documentation for details.
Reads data from the file and stores that in the given buffer.
If the file is not modified concurrently, the end-of-file is reached when the number of bytes read is zero.
Reads data from the file and stores that in the given buffer.
If the file is not modified concurrently, the end-of-file is reached when the number of bytes read is zero.
An error will be thrown if this method is called more than once or is calledafter the FileHandle is closed or closing.