fs.realpathSync()

fs.realpathSync(path[, cache]) Synchronous realpath(2). Returns the resolved path. cache is an object literal of mapped paths that can be used to force a specific path resolution or avoid additional fs.stat calls for known real paths.

fs.realpath()

fs.realpath(path[, cache], callback) Asynchronous realpath(2). The callback gets two arguments (err, resolvedPath). May use process.cwd to resolve relative paths. cache is an object literal of mapped paths that can be used to force a specific path resolution or avoid additional fs.stat calls for known real paths. Example: var cache = {'/etc':'/private/etc'}; fs.realpath('/etc/passwd', cache, (err, resolvedPath) => { if (err) throw err; console.log(resolvedPath); });

fs.ReadStream

Class: fs.ReadStream ReadStream is a Readable Stream.

fs.readlinkSync()

fs.readlinkSync(path) Synchronous readlink(2). Returns the symbolic link's string value.

fs.readlink()

fs.readlink(path, callback) Asynchronous readlink(2). The callback gets two arguments (err, linkString).

fs.readFileSync()

fs.readFileSync(file[, options]) Synchronous version of fs.readFile. Returns the contents of the file. If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.

fs.read()

fs.read(fd, buffer, offset, length, position, callback) Read data from the file specified by fd. buffer is the buffer that the data will be written to. offset is the offset in the buffer to start writing at. length is an integer specifying the number of bytes to read. position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position. The callback is given the three arguments, (err, bytesRead, buffer).

fs.readdirSync()

fs.readdirSync(path) Synchronous readdir(3). Returns an array of filenames excluding '.' and '..'.

fs.readFile()

fs.readFile(file[, options], callback) file <String> | <Integer> filename or file descriptor options <Object> | <String> encoding <String> | <Null> default = null flag <String> default = 'r' callback <Function> Asynchronously reads the entire contents of a file. Example: fs.readFile('/etc/passwd', (err, data) => { if (err) throw err; console.log(data); }); The callback is passed two arguments (err, data), where data is the conten

fs.readdir()

fs.readdir(path, callback) Asynchronous readdir(3). Reads the contents of a directory. The callback gets two arguments (err, files) where files is an array of the names of the files in the directory excluding '.' and '..'.