Browse Source

doc: add `added:` information for fs

Ref: https://github.com/nodejs/node/issues/6578
PR-URL: https://github.com/nodejs/node/pull/6717
Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v4.x
Anna Henningsen 9 years ago
committed by Myles Borins
parent
commit
1e9d27cbcc
  1. 263
      doc/api/fs.md

263
doc/api/fs.md

@ -95,10 +95,16 @@ Error: EISDIR, read
``` ```
## Class: fs.FSWatcher ## Class: fs.FSWatcher
<!-- YAML
added: v0.5.8
-->
Objects returned from `fs.watch()` are of this type. Objects returned from `fs.watch()` are of this type.
### Event: 'change' ### Event: 'change'
<!-- YAML
added: v0.5.8
-->
* `event` {String} The type of fs change * `event` {String} The type of fs change
* `filename` {String} The filename that changed (if relevant/available) * `filename` {String} The filename that changed (if relevant/available)
@ -107,35 +113,56 @@ Emitted when something changes in a watched directory or file.
See more details in [`fs.watch()`][]. See more details in [`fs.watch()`][].
### Event: 'error' ### Event: 'error'
<!-- YAML
added: v0.5.8
-->
* `error` {Error} * `error` {Error}
Emitted when an error occurs. Emitted when an error occurs.
### watcher.close() ### watcher.close()
<!-- YAML
added: v0.5.8
-->
Stop watching for changes on the given `fs.FSWatcher`. Stop watching for changes on the given `fs.FSWatcher`.
## Class: fs.ReadStream ## Class: fs.ReadStream
<!-- YAML
added: v0.1.93
-->
`ReadStream` is a [Readable Stream][]. `ReadStream` is a [Readable Stream][].
### Event: 'open' ### Event: 'open'
<!-- YAML
added: v0.1.93
-->
* `fd` {Number} Integer file descriptor used by the ReadStream. * `fd` {Number} Integer file descriptor used by the ReadStream.
Emitted when the ReadStream's file is opened. Emitted when the ReadStream's file is opened.
### Event: 'close' ### Event: 'close'
<!-- YAML
added: v0.1.93
-->
Emitted when the `ReadStream`'s underlying file descriptor has been closed Emitted when the `ReadStream`'s underlying file descriptor has been closed
using the `fs.close()` method. using the `fs.close()` method.
### readStream.path ### readStream.path
<!-- YAML
added: v0.1.93
-->
The path to the file the stream is reading from. The path to the file the stream is reading from.
## Class: fs.Stats ## Class: fs.Stats
<!-- YAML
added: v0.1.21
-->
Objects returned from [`fs.stat()`][], [`fs.lstat()`][] and [`fs.fstat()`][] and their Objects returned from [`fs.stat()`][], [`fs.lstat()`][] and [`fs.fstat()`][] and their
synchronous counterparts are of this type. synchronous counterparts are of this type.
@ -206,30 +233,48 @@ systems. Note that as of v0.12, `ctime` is not "creation time", and
on Unix systems, it never was. on Unix systems, it never was.
## Class: fs.WriteStream ## Class: fs.WriteStream
<!-- YAML
added: v0.1.93
-->
`WriteStream` is a [Writable Stream][]. `WriteStream` is a [Writable Stream][].
### Event: 'open' ### Event: 'open'
<!-- YAML
added: v0.1.93
-->
* `fd` {Number} Integer file descriptor used by the WriteStream. * `fd` {Number} Integer file descriptor used by the WriteStream.
Emitted when the WriteStream's file is opened. Emitted when the WriteStream's file is opened.
### Event: 'close' ### Event: 'close'
<!-- YAML
added: v0.1.93
-->
Emitted when the `WriteStream`'s underlying file descriptor has been closed Emitted when the `WriteStream`'s underlying file descriptor has been closed
using the `fs.close()` method. using the `fs.close()` method.
### writeStream.bytesWritten ### writeStream.bytesWritten
<!-- YAML
added: v0.4.7
-->
The number of bytes written so far. Does not include data that is still queued The number of bytes written so far. Does not include data that is still queued
for writing. for writing.
### writeStream.path ### writeStream.path
<!-- YAML
added: v0.1.93
-->
The path to the file the stream is writing to. The path to the file the stream is writing to.
## fs.access(path[, mode], callback) ## fs.access(path[, mode], callback)
<!-- YAML
added: v1.0.0
-->
Tests a user's permissions for the file specified by `path`. `mode` is an Tests a user's permissions for the file specified by `path`. `mode` is an
optional integer that specifies the accessibility checks to be performed. The optional integer that specifies the accessibility checks to be performed. The
@ -256,11 +301,17 @@ fs.access('/etc/passwd', fs.R_OK | fs.W_OK, (err) => {
``` ```
## fs.accessSync(path[, mode]) ## fs.accessSync(path[, mode])
<!-- YAML
added: v0.1.93
-->
Synchronous version of [`fs.access()`][]. This throws if any accessibility checks Synchronous version of [`fs.access()`][]. This throws if any accessibility checks
fail, and does nothing otherwise. fail, and does nothing otherwise.
## fs.appendFile(file, data[, options], callback) ## fs.appendFile(file, data[, options], callback)
<!-- YAML
added: v0.6.7
-->
* `file` {String} filename * `file` {String} filename
* `data` {String|Buffer} * `data` {String|Buffer}
@ -289,37 +340,61 @@ fs.appendFile('message.txt', 'data to append', 'utf8', callback);
``` ```
## fs.appendFileSync(file, data[, options]) ## fs.appendFileSync(file, data[, options])
<!-- YAML
added: v0.6.7
-->
The synchronous version of [`fs.appendFile()`][]. Returns `undefined`. The synchronous version of [`fs.appendFile()`][]. Returns `undefined`.
## fs.chmod(path, mode, callback) ## fs.chmod(path, mode, callback)
<!-- YAML
added: v0.1.30
-->
Asynchronous chmod(2). No arguments other than a possible exception are given Asynchronous chmod(2). No arguments other than a possible exception are given
to the completion callback. to the completion callback.
## fs.chmodSync(path, mode) ## fs.chmodSync(path, mode)
<!-- YAML
added: v0.6.7
-->
Synchronous chmod(2). Returns `undefined`. Synchronous chmod(2). Returns `undefined`.
## fs.chown(path, uid, gid, callback) ## fs.chown(path, uid, gid, callback)
<!-- YAML
added: v0.1.97
-->
Asynchronous chown(2). No arguments other than a possible exception are given Asynchronous chown(2). No arguments other than a possible exception are given
to the completion callback. to the completion callback.
## fs.chownSync(path, uid, gid) ## fs.chownSync(path, uid, gid)
<!-- YAML
added: v0.1.97
-->
Synchronous chown(2). Returns `undefined`. Synchronous chown(2). Returns `undefined`.
## fs.close(fd, callback) ## fs.close(fd, callback)
<!-- YAML
added: v0.0.2
-->
Asynchronous close(2). No arguments other than a possible exception are given Asynchronous close(2). No arguments other than a possible exception are given
to the completion callback. to the completion callback.
## fs.closeSync(fd) ## fs.closeSync(fd)
<!-- YAML
added: v0.1.21
-->
Synchronous close(2). Returns `undefined`. Synchronous close(2). Returns `undefined`.
## fs.createReadStream(path[, options]) ## fs.createReadStream(path[, options])
<!-- YAML
added: v0.1.31
-->
Returns a new [`ReadStream`][] object. (See [Readable Stream][]). Returns a new [`ReadStream`][] object. (See [Readable Stream][]).
@ -366,6 +441,9 @@ fs.createReadStream('sample.txt', {start: 90, end: 99});
If `options` is a string, then it specifies the encoding. If `options` is a string, then it specifies the encoding.
## fs.createWriteStream(path[, options]) ## fs.createWriteStream(path[, options])
<!-- YAML
added: v0.1.31
-->
Returns a new [`WriteStream`][] object. (See [Writable Stream][]). Returns a new [`WriteStream`][] object. (See [Writable Stream][]).
@ -393,6 +471,10 @@ Like [`ReadStream`][], if `fd` is specified, `WriteStream` will ignore the
If `options` is a string, then it specifies the encoding. If `options` is a string, then it specifies the encoding.
## fs.exists(path, callback) ## fs.exists(path, callback)
<!-- YAML
added: v0.0.2
deprecated: v1.0.0
-->
Stability: 0 - Deprecated: Use [`fs.stat()`][] or [`fs.access()`][] instead. Stability: 0 - Deprecated: Use [`fs.stat()`][] or [`fs.access()`][] instead.
@ -412,6 +494,10 @@ call `fs.open()` directly and handle the error raised if the file is
non-existent. non-existent.
## fs.existsSync(path) ## fs.existsSync(path)
<!-- YAML
added: v0.1.21
deprecated: v1.0.0
-->
Stability: 0 - Deprecated: Use [`fs.statSync()`][] or [`fs.accessSync()`][] instead. Stability: 0 - Deprecated: Use [`fs.statSync()`][] or [`fs.accessSync()`][] instead.
@ -419,70 +505,115 @@ Synchronous version of [`fs.exists()`][].
Returns `true` if the file exists, `false` otherwise. Returns `true` if the file exists, `false` otherwise.
## fs.fchmod(fd, mode, callback) ## fs.fchmod(fd, mode, callback)
<!-- YAML
added: v0.4.7
-->
Asynchronous fchmod(2). No arguments other than a possible exception Asynchronous fchmod(2). No arguments other than a possible exception
are given to the completion callback. are given to the completion callback.
## fs.fchmodSync(fd, mode) ## fs.fchmodSync(fd, mode)
<!-- YAML
added: v0.4.7
-->
Synchronous fchmod(2). Returns `undefined`. Synchronous fchmod(2). Returns `undefined`.
## fs.fchown(fd, uid, gid, callback) ## fs.fchown(fd, uid, gid, callback)
<!-- YAML
added: v0.4.7
-->
Asynchronous fchown(2). No arguments other than a possible exception are given Asynchronous fchown(2). No arguments other than a possible exception are given
to the completion callback. to the completion callback.
## fs.fchownSync(fd, uid, gid) ## fs.fchownSync(fd, uid, gid)
<!-- YAML
added: v0.4.7
-->
Synchronous fchown(2). Returns `undefined`. Synchronous fchown(2). Returns `undefined`.
## fs.fdatasync(fd, callback) ## fs.fdatasync(fd, callback)
<!-- YAML
added: v0.1.96
-->
Asynchronous fdatasync(2). No arguments other than a possible exception are Asynchronous fdatasync(2). No arguments other than a possible exception are
given to the completion callback. given to the completion callback.
## fs.fdatasyncSync(fd) ## fs.fdatasyncSync(fd)
<!-- YAML
added: v0.1.96
-->
Synchronous fdatasync(2). Returns `undefined`. Synchronous fdatasync(2). Returns `undefined`.
## fs.fstat(fd, callback) ## fs.fstat(fd, callback)
<!-- YAML
added: v0.1.95
-->
Asynchronous fstat(2). The callback gets two arguments `(err, stats)` where Asynchronous fstat(2). The callback gets two arguments `(err, stats)` where
`stats` is a [`fs.Stats`][] object. `fstat()` is identical to [`stat()`][], `stats` is a [`fs.Stats`][] object. `fstat()` is identical to [`stat()`][],
except that the file to be stat-ed is specified by the file descriptor `fd`. except that the file to be stat-ed is specified by the file descriptor `fd`.
## fs.fstatSync(fd) ## fs.fstatSync(fd)
<!-- YAML
added: v0.1.95
-->
Synchronous fstat(2). Returns an instance of `fs.Stats`. Synchronous fstat(2). Returns an instance of `fs.Stats`.
## fs.fsync(fd, callback) ## fs.fsync(fd, callback)
<!-- YAML
added: v0.1.96
-->
Asynchronous fsync(2). No arguments other than a possible exception are given Asynchronous fsync(2). No arguments other than a possible exception are given
to the completion callback. to the completion callback.
## fs.fsyncSync(fd) ## fs.fsyncSync(fd)
<!-- YAML
added: v0.1.96
-->
Synchronous fsync(2). Returns `undefined`. Synchronous fsync(2). Returns `undefined`.
## fs.ftruncate(fd, len, callback) ## fs.ftruncate(fd, len, callback)
<!-- YAML
added: v0.8.6
-->
Asynchronous ftruncate(2). No arguments other than a possible exception are Asynchronous ftruncate(2). No arguments other than a possible exception are
given to the completion callback. given to the completion callback.
## fs.ftruncateSync(fd, len) ## fs.ftruncateSync(fd, len)
<!-- YAML
added: v0.8.6
-->
Synchronous ftruncate(2). Returns `undefined`. Synchronous ftruncate(2). Returns `undefined`.
## fs.futimes(fd, atime, mtime, callback) ## fs.futimes(fd, atime, mtime, callback)
<!-- YAML
added: v0.4.2
-->
Change the file timestamps of a file referenced by the supplied file Change the file timestamps of a file referenced by the supplied file
descriptor. descriptor.
## fs.futimesSync(fd, atime, mtime) ## fs.futimesSync(fd, atime, mtime)
<!-- YAML
added: v0.4.2
-->
Synchronous version of [`fs.futimes()`][]. Returns `undefined`. Synchronous version of [`fs.futimes()`][]. Returns `undefined`.
## fs.lchmod(path, mode, callback) ## fs.lchmod(path, mode, callback)
<!-- YAML
deprecated: v0.4.7
-->
Asynchronous lchmod(2). No arguments other than a possible exception Asynchronous lchmod(2). No arguments other than a possible exception
are given to the completion callback. are given to the completion callback.
@ -490,28 +621,46 @@ are given to the completion callback.
Only available on Mac OS X. Only available on Mac OS X.
## fs.lchmodSync(path, mode) ## fs.lchmodSync(path, mode)
<!-- YAML
deprecated: v0.4.7
-->
Synchronous lchmod(2). Returns `undefined`. Synchronous lchmod(2). Returns `undefined`.
## fs.lchown(path, uid, gid, callback) ## fs.lchown(path, uid, gid, callback)
<!-- YAML
deprecated: v0.4.7
-->
Asynchronous lchown(2). No arguments other than a possible exception are given Asynchronous lchown(2). No arguments other than a possible exception are given
to the completion callback. to the completion callback.
## fs.lchownSync(path, uid, gid) ## fs.lchownSync(path, uid, gid)
<!-- YAML
deprecated: v0.4.7
-->
Synchronous lchown(2). Returns `undefined`. Synchronous lchown(2). Returns `undefined`.
## fs.link(srcpath, dstpath, callback) ## fs.link(srcpath, dstpath, callback)
<!-- YAML
added: v0.1.31
-->
Asynchronous link(2). No arguments other than a possible exception are given to Asynchronous link(2). No arguments other than a possible exception are given to
the completion callback. the completion callback.
## fs.linkSync(srcpath, dstpath) ## fs.linkSync(srcpath, dstpath)
<!-- YAML
added: v0.1.31
-->
Synchronous link(2). Returns `undefined`. Synchronous link(2). Returns `undefined`.
## fs.lstat(path, callback) ## fs.lstat(path, callback)
<!-- YAML
added: v0.1.30
-->
Asynchronous lstat(2). The callback gets two arguments `(err, stats)` where Asynchronous lstat(2). The callback gets two arguments `(err, stats)` where
`stats` is a [`fs.Stats`][] object. `lstat()` is identical to `stat()`, `stats` is a [`fs.Stats`][] object. `lstat()` is identical to `stat()`,
@ -519,19 +668,31 @@ except that if `path` is a symbolic link, then the link itself is stat-ed,
not the file that it refers to. not the file that it refers to.
## fs.lstatSync(path) ## fs.lstatSync(path)
<!-- YAML
added: v0.1.30
-->
Synchronous lstat(2). Returns an instance of `fs.Stats`. Synchronous lstat(2). Returns an instance of `fs.Stats`.
## fs.mkdir(path[, mode], callback) ## fs.mkdir(path[, mode], callback)
<!-- YAML
added: v0.1.8
-->
Asynchronous mkdir(2). No arguments other than a possible exception are given Asynchronous mkdir(2). No arguments other than a possible exception are given
to the completion callback. `mode` defaults to `0o777`. to the completion callback. `mode` defaults to `0o777`.
## fs.mkdirSync(path[, mode]) ## fs.mkdirSync(path[, mode])
<!-- YAML
added: v0.1.21
-->
Synchronous mkdir(2). Returns `undefined`. Synchronous mkdir(2). Returns `undefined`.
## fs.open(path, flags[, mode], callback) ## fs.open(path, flags[, mode], callback)
<!-- YAML
added: v0.0.2
-->
Asynchronous file open. See open(2). `flags` can be: Asynchronous file open. See open(2). `flags` can be:
@ -594,11 +755,17 @@ The kernel ignores the position argument and always appends the data to
the end of the file. the end of the file.
## fs.openSync(path, flags[, mode]) ## fs.openSync(path, flags[, mode])
<!-- YAML
added: v0.1.21
-->
Synchronous version of [`fs.open()`][]. Returns an integer representing the file Synchronous version of [`fs.open()`][]. Returns an integer representing the file
descriptor. descriptor.
## fs.read(fd, buffer, offset, length, position, callback) ## fs.read(fd, buffer, offset, length, position, callback)
<!-- YAML
added: v0.0.2
-->
Read data from the file specified by `fd`. Read data from the file specified by `fd`.
@ -614,17 +781,26 @@ If `position` is `null`, data will be read from the current file position.
The callback is given the three arguments, `(err, bytesRead, buffer)`. The callback is given the three arguments, `(err, bytesRead, buffer)`.
## fs.readdir(path, callback) ## fs.readdir(path, callback)
<!-- YAML
added: v0.1.8
-->
Asynchronous readdir(3). Reads the contents of a directory. Asynchronous readdir(3). Reads the contents of a directory.
The callback gets two arguments `(err, files)` where `files` is an array of The callback gets two arguments `(err, files)` where `files` is an array of
the names of the files in the directory excluding `'.'` and `'..'`. the names of the files in the directory excluding `'.'` and `'..'`.
## fs.readdirSync(path) ## fs.readdirSync(path)
<!-- YAML
added: v0.1.21
-->
Synchronous readdir(3). Returns an array of filenames excluding `'.'` and Synchronous readdir(3). Returns an array of filenames excluding `'.'` and
`'..'`. `'..'`.
## fs.readFile(file[, options], callback) ## fs.readFile(file[, options], callback)
<!-- YAML
added: v0.1.29
-->
* `file` {String} filename * `file` {String} filename
* `options` {Object | String} * `options` {Object | String}
@ -653,6 +829,9 @@ fs.readFile('/etc/passwd', 'utf8', callback);
``` ```
## fs.readFileSync(file[, options]) ## fs.readFileSync(file[, options])
<!-- YAML
added: v0.1.8
-->
Synchronous version of [`fs.readFile`][]. Returns the contents of the `file`. Synchronous version of [`fs.readFile`][]. Returns the contents of the `file`.
@ -660,15 +839,24 @@ If the `encoding` option is specified then this function returns a
string. Otherwise it returns a buffer. string. Otherwise it returns a buffer.
## fs.readlink(path, callback) ## fs.readlink(path, callback)
<!-- YAML
added: v0.1.31
-->
Asynchronous readlink(2). The callback gets two arguments `(err, Asynchronous readlink(2). The callback gets two arguments `(err,
linkString)`. linkString)`.
## fs.readlinkSync(path) ## fs.readlinkSync(path)
<!-- YAML
added: v0.1.31
-->
Synchronous readlink(2). Returns the symbolic link's string value. Synchronous readlink(2). Returns the symbolic link's string value.
## fs.realpath(path[, cache], callback) ## fs.realpath(path[, cache], callback)
<!-- YAML
added: v0.1.31
-->
Asynchronous realpath(2). The `callback` gets two arguments `(err, Asynchronous realpath(2). The `callback` gets two arguments `(err,
resolvedPath)`. May use `process.cwd` to resolve relative paths. `cache` is an resolvedPath)`. May use `process.cwd` to resolve relative paths. `cache` is an
@ -686,44 +874,71 @@ fs.realpath('/etc/passwd', cache, (err, resolvedPath) => {
``` ```
## fs.readSync(fd, buffer, offset, length, position) ## fs.readSync(fd, buffer, offset, length, position)
<!-- YAML
added: v0.1.21
-->
Synchronous version of [`fs.read()`][]. Returns the number of `bytesRead`. Synchronous version of [`fs.read()`][]. Returns the number of `bytesRead`.
## fs.realpathSync(path[, cache]) ## fs.realpathSync(path[, cache])
<!-- YAML
added: v0.1.31
-->
Synchronous realpath(2). Returns the resolved path. `cache` is an Synchronous realpath(2). Returns the resolved path. `cache` is an
object literal of mapped paths that can be used to force a specific path 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. resolution or avoid additional `fs.stat` calls for known real paths.
## fs.rename(oldPath, newPath, callback) ## fs.rename(oldPath, newPath, callback)
<!-- YAML
added: v0.0.2
-->
Asynchronous rename(2). No arguments other than a possible exception are given Asynchronous rename(2). No arguments other than a possible exception are given
to the completion callback. to the completion callback.
## fs.renameSync(oldPath, newPath) ## fs.renameSync(oldPath, newPath)
<!-- YAML
added: v0.1.21
-->
Synchronous rename(2). Returns `undefined`. Synchronous rename(2). Returns `undefined`.
## fs.rmdir(path, callback) ## fs.rmdir(path, callback)
<!-- YAML
added: v0.0.2
-->
Asynchronous rmdir(2). No arguments other than a possible exception are given Asynchronous rmdir(2). No arguments other than a possible exception are given
to the completion callback. to the completion callback.
## fs.rmdirSync(path) ## fs.rmdirSync(path)
<!-- YAML
added: v0.1.21
-->
Synchronous rmdir(2). Returns `undefined`. Synchronous rmdir(2). Returns `undefined`.
## fs.stat(path, callback) ## fs.stat(path, callback)
<!-- YAML
added: v0.0.2
-->
Asynchronous stat(2). The callback gets two arguments `(err, stats)` where Asynchronous stat(2). The callback gets two arguments `(err, stats)` where
`stats` is a [`fs.Stats`][] object. See the [`fs.Stats`][] section for more `stats` is a [`fs.Stats`][] object. See the [`fs.Stats`][] section for more
information. information.
## fs.statSync(path) ## fs.statSync(path)
<!-- YAML
added: v0.1.21
-->
Synchronous stat(2). Returns an instance of [`fs.Stats`][]. Synchronous stat(2). Returns an instance of [`fs.Stats`][].
## fs.symlink(target, path[, type], callback) ## fs.symlink(target, path[, type], callback)
<!-- YAML
added: v0.1.31
-->
Asynchronous symlink(2). No arguments other than a possible exception are given Asynchronous symlink(2). No arguments other than a possible exception are given
to the completion callback. to the completion callback.
@ -741,29 +956,47 @@ fs.symlink('./foo', './new-port');
It creates a symbolic link named "new-port" that points to "foo". It creates a symbolic link named "new-port" that points to "foo".
## fs.symlinkSync(target, path[, type]) ## fs.symlinkSync(target, path[, type])
<!-- YAML
added: v0.1.31
-->
Synchronous symlink(2). Returns `undefined`. Synchronous symlink(2). Returns `undefined`.
## fs.truncate(path, len, callback) ## fs.truncate(path, len, callback)
<!-- YAML
added: v0.8.6
-->
Asynchronous truncate(2). No arguments other than a possible exception are Asynchronous truncate(2). No arguments other than a possible exception are
given to the completion callback. A file descriptor can also be passed as the given to the completion callback. A file descriptor can also be passed as the
first argument. In this case, `fs.ftruncate()` is called. first argument. In this case, `fs.ftruncate()` is called.
## fs.truncateSync(path, len) ## fs.truncateSync(path, len)
<!-- YAML
added: v0.8.6
-->
Synchronous truncate(2). Returns `undefined`. Synchronous truncate(2). Returns `undefined`.
## fs.unlink(path, callback) ## fs.unlink(path, callback)
<!-- YAML
added: v0.0.2
-->
Asynchronous unlink(2). No arguments other than a possible exception are given Asynchronous unlink(2). No arguments other than a possible exception are given
to the completion callback. to the completion callback.
## fs.unlinkSync(path) ## fs.unlinkSync(path)
<!-- YAML
added: v0.1.21
-->
Synchronous unlink(2). Returns `undefined`. Synchronous unlink(2). Returns `undefined`.
## fs.unwatchFile(filename[, listener]) ## fs.unwatchFile(filename[, listener])
<!-- YAML
added: v0.1.31
-->
Stop watching for changes on `filename`. If `listener` is specified, only that Stop watching for changes on `filename`. If `listener` is specified, only that
particular listener is removed. Otherwise, *all* listeners are removed and you particular listener is removed. Otherwise, *all* listeners are removed and you
@ -777,6 +1010,9 @@ _Note: [`fs.watch()`][] is more efficient than `fs.watchFile()` and `fs.unwatchF
when possible._ when possible._
## fs.utimes(path, atime, mtime, callback) ## fs.utimes(path, atime, mtime, callback)
<!-- YAML
added: v0.4.2
-->
Change file timestamps of the file referenced by the supplied path. Change file timestamps of the file referenced by the supplied path.
@ -789,10 +1025,16 @@ follow the below rules:
`Date.now()`. `Date.now()`.
## fs.utimesSync(path, atime, mtime) ## fs.utimesSync(path, atime, mtime)
<!-- YAML
added: v0.4.2
-->
Synchronous version of [`fs.utimes()`][]. Returns `undefined`. Synchronous version of [`fs.utimes()`][]. Returns `undefined`.
## fs.watch(filename[, options][, listener]) ## fs.watch(filename[, options][, listener])
<!-- YAML
added: v0.5.10
-->
Watch for changes on `filename`, where `filename` is either a file or a Watch for changes on `filename`, where `filename` is either a file or a
directory. The returned object is a [`fs.FSWatcher`][]. directory. The returned object is a [`fs.FSWatcher`][].
@ -873,6 +1115,9 @@ fs.watch('somedir', (event, filename) => {
``` ```
## fs.watchFile(filename[, options], listener) ## fs.watchFile(filename[, options], listener)
<!-- YAML
added: v0.1.31
-->
Watch for changes on `filename`. The callback `listener` will be called each Watch for changes on `filename`. The callback `listener` will be called each
time the file is accessed. time the file is accessed.
@ -910,6 +1155,9 @@ _Note: [`fs.watch()`][] is more efficient than `fs.watchFile` and `fs.unwatchFil
when possible._ when possible._
## fs.write(fd, buffer, offset, length[, position], callback) ## fs.write(fd, buffer, offset, length[, position], callback)
<!-- YAML
added: v0.0.2
-->
Write `buffer` to the file specified by `fd`. Write `buffer` to the file specified by `fd`.
@ -931,6 +1179,9 @@ The kernel ignores the position argument and always appends the data to
the end of the file. the end of the file.
## fs.write(fd, data[, position[, encoding]], callback) ## fs.write(fd, data[, position[, encoding]], callback)
<!-- YAML
added: v0.11.5
-->
Write `data` to the file specified by `fd`. If `data` is not a Buffer instance Write `data` to the file specified by `fd`. If `data` is not a Buffer instance
then the value will be coerced to a string. then the value will be coerced to a string.
@ -958,6 +1209,9 @@ The kernel ignores the position argument and always appends the data to
the end of the file. the end of the file.
## fs.writeFile(file, data[, options], callback) ## fs.writeFile(file, data[, options], callback)
<!-- YAML
added: v0.1.29
-->
* `file` {String} filename * `file` {String} filename
* `data` {String | Buffer} * `data` {String | Buffer}
@ -993,12 +1247,21 @@ without waiting for the callback. For this scenario,
`fs.createWriteStream` is strongly recommended. `fs.createWriteStream` is strongly recommended.
## fs.writeFileSync(file, data[, options]) ## fs.writeFileSync(file, data[, options])
<!-- YAML
added: v0.1.29
-->
The synchronous version of [`fs.writeFile()`][]. Returns `undefined`. The synchronous version of [`fs.writeFile()`][]. Returns `undefined`.
## fs.writeSync(fd, buffer, offset, length[, position]) ## fs.writeSync(fd, buffer, offset, length[, position])
<!-- YAML
added: v0.1.21
-->
## fs.writeSync(fd, data[, position[, encoding]]) ## fs.writeSync(fd, data[, position[, encoding]])
<!-- YAML
added: v0.11.5
-->
Synchronous versions of [`fs.write()`][]. Returns the number of bytes written. Synchronous versions of [`fs.write()`][]. Returns the number of bytes written.

Loading…
Cancel
Save