From 9bcb2cc8e33ce360605841e91a286c0183bf131a Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 12 May 2016 20:52:39 +0200 Subject: [PATCH] doc: add `added:` information for fs Ref: https://github.com/nodejs/node/issues/6578 --- doc/api/fs.md | 272 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 272 insertions(+) diff --git a/doc/api/fs.md b/doc/api/fs.md index 895d5c5e931c00..f5e0273d8638bd 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -95,6 +95,9 @@ Error: EISDIR, read ``` ## Buffer API + `fs` functions support passing and receiving paths as both strings and Buffers. The latter is intended to make it possible to work with @@ -107,10 +110,16 @@ will always be encoded as UTF-8. On such file systems, passing non-UTF-8 encoded Buffers to `fs` functions will not work as expected. ## Class: fs.FSWatcher + Objects returned from `fs.watch()` are of this type. ### Event: 'change' + * `event` {String} The type of fs change * `filename` {String | Buffer} The filename that changed (if relevant/available) @@ -132,31 +141,49 @@ fs.watch('./tmp', {encoding: 'buffer'}, (event, filename) => { ``` ### Event: 'error' + * `error` {Error} Emitted when an error occurs. ### watcher.close() + Stop watching for changes on the given `fs.FSWatcher`. ## Class: fs.ReadStream + `ReadStream` is a [Readable Stream][]. ### Event: 'open' + * `fd` {Integer} Integer file descriptor used by the ReadStream. Emitted when the ReadStream's file is opened. ### Event: 'close' + Emitted when the `ReadStream`'s underlying file descriptor has been closed using the `fs.close()` method. ### readStream.path + The path to the file the stream is reading from as specified in the first argument to `fs.createReadStream()`. If `path` is passed as a string, then @@ -164,6 +191,9 @@ argument to `fs.createReadStream()`. If `path` is passed as a string, then `readStream.path` will be a `Buffer`. ## Class: fs.Stats + Objects returned from [`fs.stat()`][], [`fs.lstat()`][] and [`fs.fstat()`][] and their synchronous counterparts are of this type. @@ -234,26 +264,41 @@ systems. Note that as of v0.12, `ctime` is not "creation time", and on Unix systems, it never was. ## Class: fs.WriteStream + `WriteStream` is a [Writable Stream][]. ### Event: 'open' + * `fd` {Integer} Integer file descriptor used by the WriteStream. Emitted when the WriteStream's file is opened. ### Event: 'close' + Emitted when the `WriteStream`'s underlying file descriptor has been closed using the `fs.close()` method. ### writeStream.bytesWritten + The number of bytes written so far. Does not include data that is still queued for writing. ### writeStream.path + The path to the file the stream is writing to as specified in the first argument to `fs.createWriteStream()`. If `path` is passed as a string, then @@ -261,6 +306,9 @@ argument to `fs.createWriteStream()`. If `path` is passed as a string, then `writeStream.path` will be a `Buffer`. ## fs.access(path[, mode], callback) + * `path` {String | Buffer} * `mode` {Integer} @@ -291,6 +339,9 @@ fs.access('/etc/passwd', fs.R_OK | fs.W_OK, (err) => { ``` ## fs.accessSync(path[, mode]) + * `path` {String | Buffer} * `mode` {Integer} @@ -299,6 +350,9 @@ Synchronous version of [`fs.access()`][]. This throws if any accessibility check fail, and does nothing otherwise. ## fs.appendFile(file, data[, options], callback) + * `file` {String | Buffer | Number} filename or file descriptor * `data` {String | Buffer} @@ -331,6 +385,9 @@ Any specified file descriptor has to have been opened for appending. _Note: Specified file descriptors will not be closed automatically._ ## fs.appendFileSync(file, data[, options]) + * `file` {String | Buffer} * `data` {String | Buffer} @@ -342,6 +399,9 @@ _Note: Specified file descriptors will not be closed automatically._ The synchronous version of [`fs.appendFile()`][]. Returns `undefined`. ## fs.chmod(path, mode, callback) + * `path` {String | Buffer} * `mode` {Integer} @@ -351,6 +411,9 @@ Asynchronous chmod(2). No arguments other than a possible exception are given to the completion callback. ## fs.chmodSync(path, mode) + * `path` {String | Buffer} * `mode` {Integer} @@ -358,6 +421,9 @@ to the completion callback. Synchronous chmod(2). Returns `undefined`. ## fs.chown(path, uid, gid, callback) + * `path` {String | Buffer} * `uid` {Integer} @@ -368,6 +434,9 @@ Asynchronous chown(2). No arguments other than a possible exception are given to the completion callback. ## fs.chownSync(path, uid, gid) + * `path` {String | Buffer} * `uid` {Integer} @@ -376,6 +445,9 @@ to the completion callback. Synchronous chown(2). Returns `undefined`. ## fs.close(fd, callback) + * `fd` {Integer} * `callback` {Function} @@ -384,12 +456,18 @@ Asynchronous close(2). No arguments other than a possible exception are given to the completion callback. ## fs.closeSync(fd) + * `fd` {Integer} Synchronous close(2). Returns `undefined`. ## fs.createReadStream(path[, options]) + * `path` {String | Buffer} * `options` {String | Object} @@ -446,6 +524,9 @@ fs.createReadStream('sample.txt', {start: 90, end: 99}); If `options` is a string, then it specifies the encoding. ## fs.createWriteStream(path[, options]) + * `path` {String | Buffer} * `options` {String | Object} @@ -489,6 +570,10 @@ Like [`ReadStream`][], if `fd` is specified, `WriteStream` will ignore the If `options` is a string, then it specifies the encoding. ## fs.exists(path, callback) + Stability: 0 - Deprecated: Use [`fs.stat()`][] or [`fs.access()`][] instead. @@ -511,6 +596,10 @@ call `fs.open()` directly and handle the error raised if the file is non-existent. ## fs.existsSync(path) + Stability: 0 - Deprecated: Use [`fs.statSync()`][] or [`fs.accessSync()`][] instead. @@ -520,6 +609,9 @@ Synchronous version of [`fs.exists()`][]. Returns `true` if the file exists, `false` otherwise. ## fs.fchmod(fd, mode, callback) + * `fd` {Integer} * `mode` {Integer} @@ -529,6 +621,9 @@ Asynchronous fchmod(2). No arguments other than a possible exception are given to the completion callback. ## fs.fchmodSync(fd, mode) + * `fd` {Integer} * `mode` {Integer} @@ -536,6 +631,9 @@ are given to the completion callback. Synchronous fchmod(2). Returns `undefined`. ## fs.fchown(fd, uid, gid, callback) + * `fd` {Integer} * `uid` {Integer} @@ -546,6 +644,9 @@ Asynchronous fchown(2). No arguments other than a possible exception are given to the completion callback. ## fs.fchownSync(fd, uid, gid) + * `fd` {Integer} * `uid` {Integer} @@ -554,6 +655,9 @@ to the completion callback. Synchronous fchown(2). Returns `undefined`. ## fs.fdatasync(fd, callback) + * `fd` {Integer} * `callback` {Function} @@ -562,12 +666,18 @@ Asynchronous fdatasync(2). No arguments other than a possible exception are given to the completion callback. ## fs.fdatasyncSync(fd) + * `fd` {Integer} Synchronous fdatasync(2). Returns `undefined`. ## fs.fstat(fd, callback) + * `fd` {Integer} * `callback` {Function} @@ -577,12 +687,18 @@ Asynchronous fstat(2). The callback gets two arguments `(err, stats)` where except that the file to be stat-ed is specified by the file descriptor `fd`. ## fs.fstatSync(fd) + * `fd` {Integer} Synchronous fstat(2). Returns an instance of `fs.Stats`. ## fs.fsync(fd, callback) + * `fd` {Integer} * `callback` {Function} @@ -591,12 +707,18 @@ Asynchronous fsync(2). No arguments other than a possible exception are given to the completion callback. ## fs.fsyncSync(fd) + * `fd` {Integer} Synchronous fsync(2). Returns `undefined`. ## fs.ftruncate(fd, len, callback) + * `fd` {Integer} * `len` {Integer} @@ -606,6 +728,9 @@ Asynchronous ftruncate(2). No arguments other than a possible exception are given to the completion callback. ## fs.ftruncateSync(fd, len) + * `fd` {Integer} * `len` {Integer} @@ -613,6 +738,9 @@ given to the completion callback. Synchronous ftruncate(2). Returns `undefined`. ## fs.futimes(fd, atime, mtime, callback) + * `fd` {Integer} * `atime` {Integer} @@ -623,6 +751,9 @@ Change the file timestamps of a file referenced by the supplied file descriptor. ## fs.futimesSync(fd, atime, mtime) + * `fd` {Integer} * `atime` {Integer} @@ -631,6 +762,9 @@ descriptor. Synchronous version of [`fs.futimes()`][]. Returns `undefined`. ## fs.lchmod(path, mode, callback) + * `path` {String | Buffer} * `mode` {Integer} @@ -642,6 +776,9 @@ are given to the completion callback. Only available on Mac OS X. ## fs.lchmodSync(path, mode) + * `path` {String | Buffer} * `mode` {Integer} @@ -649,6 +786,9 @@ Only available on Mac OS X. Synchronous lchmod(2). Returns `undefined`. ## fs.lchown(path, uid, gid, callback) + * `path` {String | Buffer} * `uid` {Integer} @@ -659,6 +799,9 @@ Asynchronous lchown(2). No arguments other than a possible exception are given to the completion callback. ## fs.lchownSync(path, uid, gid) + * `path` {String | Buffer} * `uid` {Integer} @@ -667,6 +810,9 @@ to the completion callback. Synchronous lchown(2). Returns `undefined`. ## fs.link(srcpath, dstpath, callback) + * `srcpath` {String | Buffer} * `dstpath` {String | Buffer} @@ -676,6 +822,9 @@ Asynchronous link(2). No arguments other than a possible exception are given to the completion callback. ## fs.linkSync(srcpath, dstpath) + * `srcpath` {String | Buffer} * `dstpath` {String | Buffer} @@ -683,6 +832,9 @@ the completion callback. Synchronous link(2). Returns `undefined`. ## fs.lstat(path, callback) + * `path` {String | Buffer} * `callback` {Function} @@ -693,12 +845,18 @@ except that if `path` is a symbolic link, then the link itself is stat-ed, not the file that it refers to. ## fs.lstatSync(path) + * `path` {String | Buffer} Synchronous lstat(2). Returns an instance of `fs.Stats`. ## fs.mkdir(path[, mode], callback) + * `path` {String | Buffer} * `mode` {Integer} @@ -708,6 +866,9 @@ Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. `mode` defaults to `0o777`. ## fs.mkdirSync(path[, mode]) + * `path` {String | Buffer} * `mode` {Integer} @@ -715,6 +876,9 @@ to the completion callback. `mode` defaults to `0o777`. Synchronous mkdir(2). Returns `undefined`. ## fs.mkdtemp(prefix, callback) + Creates a unique temporary directory. @@ -734,11 +898,17 @@ fs.mkdtemp('/tmp/foo-', (err, folder) => { ``` ## fs.mkdtempSync(template) + The synchronous version of [`fs.mkdtemp()`][]. Returns the created folder path. ## fs.open(path, flags[, mode], callback) + * `path` {String | Buffer} * `flags` {String | Number} @@ -823,6 +993,9 @@ fs.open('', 'a+', (err, fd) => { ``` ## fs.openSync(path, flags[, mode]) + * `path` {String | Buffer} * `flags` {String | Number} @@ -832,6 +1005,9 @@ Synchronous version of [`fs.open()`][]. Returns an integer representing the file descriptor. ## fs.read(fd, buffer, offset, length, position, callback) + * `fd` {Integer} * `buffer` {String | Buffer} @@ -854,6 +1030,9 @@ If `position` is `null`, data will be read from the current file position. The callback is given the three arguments, `(err, bytesRead, buffer)`. ## fs.readdir(path[, options], callback) + * `path` {String | Buffer} * `options` {String | Object} @@ -870,6 +1049,9 @@ the filenames passed to the callback. If the `encoding` is set to `'buffer'`, the filenames returned will be passed as `Buffer` objects. ## fs.readdirSync(path[, options]) + * `path` {String | Buffer} * `options` {String | Object} @@ -884,6 +1066,9 @@ the filenames passed to the callback. If the `encoding` is set to `'buffer'`, the filenames returned will be passed as `Buffer` objects. ## fs.readFile(file[, options], callback) + * `file` {String | Buffer | Integer} filename or file descriptor * `options` {Object | String} @@ -916,6 +1101,9 @@ Any specified file descriptor has to support reading. _Note: Specified file descriptors will not be closed automatically._ ## fs.readFileSync(file[, options]) + * `file` {String | Buffer | Integer} filename or file descriptor * `options` {Object | String} @@ -928,6 +1116,9 @@ If the `encoding` option is specified then this function returns a string. Otherwise it returns a buffer. ## fs.readlink(path[, options], callback) + * `path` {String | Buffer} * `options` {String | Object} @@ -943,6 +1134,9 @@ the link path passed to the callback. If the `encoding` is set to `'buffer'`, the link path returned will be passed as a `Buffer` object. ## fs.readlinkSync(path[, options]) + * `path` {String | Buffer} * `options` {String | Object} @@ -956,6 +1150,9 @@ the link path passed to the callback. If the `encoding` is set to `'buffer'`, the link path returned will be passed as a `Buffer` object. ## fs.readSync(fd, buffer, offset, length, position) + * `fd` {Integer} * `buffer` {String | Buffer} @@ -966,6 +1163,9 @@ the link path returned will be passed as a `Buffer` object. Synchronous version of [`fs.read()`][]. Returns the number of `bytesRead`. ## fs.realpath(path[, options], callback) + * `path` {String | Buffer} * `options` {String | Object} @@ -981,6 +1181,9 @@ the path passed to the callback. If the `encoding` is set to `'buffer'`, the path returned will be passed as a `Buffer` object. ## fs.realpathSync(path[, options]) + * `path` {String | Buffer}; * `options` {String | Object} @@ -994,6 +1197,9 @@ the path passed to the callback. If the `encoding` is set to `'buffer'`, the path returned will be passed as a `Buffer` object. ## fs.rename(oldPath, newPath, callback) + * `oldPath` {String | Buffer} * `newPath` {String | Buffer} @@ -1003,6 +1209,9 @@ Asynchronous rename(2). No arguments other than a possible exception are given to the completion callback. ## fs.renameSync(oldPath, newPath) + * `oldPath` {String | Buffer} * `newPath` {String | Buffer} @@ -1010,6 +1219,9 @@ to the completion callback. Synchronous rename(2). Returns `undefined`. ## fs.rmdir(path, callback) + * `path` {String | Buffer} * `callback` {Function} @@ -1018,12 +1230,18 @@ Asynchronous rmdir(2). No arguments other than a possible exception are given to the completion callback. ## fs.rmdirSync(path) + * `path` {String | Buffer} Synchronous rmdir(2). Returns `undefined`. ## fs.stat(path, callback) + * `path` {String | Buffer} * `callback` {Function} @@ -1033,12 +1251,18 @@ Asynchronous stat(2). The callback gets two arguments `(err, stats)` where information. ## fs.statSync(path) + * `path` {String | Buffer} Synchronous stat(2). Returns an instance of [`fs.Stats`][]. ## fs.symlink(target, path[, type], callback) + * `target` {String | Buffer} * `path` {String | Buffer} @@ -1061,6 +1285,9 @@ fs.symlink('./foo', './new-port'); It creates a symbolic link named "new-port" that points to "foo". ## fs.symlinkSync(target, path[, type]) + * `target` {String | Buffer} * `path` {String | Buffer} @@ -1069,6 +1296,9 @@ It creates a symbolic link named "new-port" that points to "foo". Synchronous symlink(2). Returns `undefined`. ## fs.truncate(path, len, callback) + * `path` {String | Buffer} * `len` {Integer} @@ -1079,6 +1309,9 @@ given to the completion callback. A file descriptor can also be passed as the first argument. In this case, `fs.ftruncate()` is called. ## fs.truncateSync(path, len) + * `path` {String | Buffer} * `len` {Integer} @@ -1086,6 +1319,9 @@ first argument. In this case, `fs.ftruncate()` is called. Synchronous truncate(2). Returns `undefined`. ## fs.unlink(path, callback) + * `path` {String | Buffer} * `callback` {Function} @@ -1094,12 +1330,18 @@ Asynchronous unlink(2). No arguments other than a possible exception are given to the completion callback. ## fs.unlinkSync(path) + * `path` {String | Buffer} Synchronous unlink(2). Returns `undefined`. ## fs.unwatchFile(filename[, listener]) + * `filename` {String | Buffer} * `listener` {Function} @@ -1116,6 +1358,9 @@ _Note: [`fs.watch()`][] is more efficient than `fs.watchFile()` and `fs.unwatchF when possible._ ## fs.utimes(path, atime, mtime, callback) + * `path` {String | Buffer} * `atime` {Integer} @@ -1133,6 +1378,9 @@ follow the below rules: `Date.now()`. ## fs.utimesSync(path, atime, mtime) + * `path` {String | Buffer} * `atime` {Integer} @@ -1141,6 +1389,9 @@ follow the below rules: Synchronous version of [`fs.utimes()`][]. Returns `undefined`. ## fs.watch(filename[, options][, listener]) + * `filename` {String | Buffer} * `options` {String | Object} @@ -1225,6 +1476,9 @@ fs.watch('somedir', (event, filename) => { ``` ## fs.watchFile(filename[, options], listener) + * `filename` {String | Buffer} * `options` {Object} @@ -1268,6 +1522,9 @@ _Note: [`fs.watch()`][] is more efficient than `fs.watchFile` and `fs.unwatchFil when possible._ ## fs.write(fd, buffer, offset, length[, position], callback) + * `fd` {Integer} * `buffer` {String | Buffer} @@ -1296,6 +1553,9 @@ The kernel ignores the position argument and always appends the data to the end of the file. ## fs.write(fd, data[, position[, encoding]], callback) + * `fd` {Integer} * `data` {String | Buffer} @@ -1329,6 +1589,9 @@ The kernel ignores the position argument and always appends the data to the end of the file. ## fs.writeFile(file, data[, options], callback) + * `file` {String | Buffer | Integer} filename or file descriptor * `data` {String | Buffer} @@ -1368,6 +1631,9 @@ without waiting for the callback. For this scenario, _Note: Specified file descriptors will not be closed automatically._ ## fs.writeFileSync(file, data[, options]) + * `file` {String | Buffer | Integer} filename or file descriptor * `data` {String | Buffer} @@ -1379,6 +1645,9 @@ _Note: Specified file descriptors will not be closed automatically._ The synchronous version of [`fs.writeFile()`][]. Returns `undefined`. ## fs.writeSync(fd, buffer, offset, length[, position]) + * `fd` {Integer} * `buffer` {String | Buffer} @@ -1387,6 +1656,9 @@ The synchronous version of [`fs.writeFile()`][]. Returns `undefined`. * `position` {Integer} ## fs.writeSync(fd, data[, position[, encoding]]) + * `fd` {Integer} * `data` {String | Buffer}