|
|
@ -70,7 +70,7 @@ warning. |
|
|
|
errors as exceptions. |
|
|
|
|
|
|
|
|
|
|
|
## fs.rename(oldPath, newPath, [callback]) |
|
|
|
## fs.rename(oldPath, newPath, callback) |
|
|
|
|
|
|
|
Asynchronous rename(2). No arguments other than a possible exception are given |
|
|
|
to the completion callback. |
|
|
@ -79,7 +79,7 @@ to the completion callback. |
|
|
|
|
|
|
|
Synchronous rename(2). |
|
|
|
|
|
|
|
## fs.ftruncate(fd, len, [callback]) |
|
|
|
## fs.ftruncate(fd, len, callback) |
|
|
|
|
|
|
|
Asynchronous ftruncate(2). No arguments other than a possible exception are |
|
|
|
given to the completion callback. |
|
|
@ -88,7 +88,7 @@ given to the completion callback. |
|
|
|
|
|
|
|
Synchronous ftruncate(2). |
|
|
|
|
|
|
|
## fs.truncate(path, len, [callback]) |
|
|
|
## fs.truncate(path, len, callback) |
|
|
|
|
|
|
|
Asynchronous truncate(2). No arguments other than a possible exception are |
|
|
|
given to the completion callback. |
|
|
@ -97,7 +97,7 @@ given to the completion callback. |
|
|
|
|
|
|
|
Synchronous truncate(2). |
|
|
|
|
|
|
|
## fs.chown(path, uid, gid, [callback]) |
|
|
|
## fs.chown(path, uid, gid, callback) |
|
|
|
|
|
|
|
Asynchronous chown(2). No arguments other than a possible exception are given |
|
|
|
to the completion callback. |
|
|
@ -106,7 +106,7 @@ to the completion callback. |
|
|
|
|
|
|
|
Synchronous chown(2). |
|
|
|
|
|
|
|
## fs.fchown(fd, uid, gid, [callback]) |
|
|
|
## fs.fchown(fd, uid, gid, callback) |
|
|
|
|
|
|
|
Asynchronous fchown(2). No arguments other than a possible exception are given |
|
|
|
to the completion callback. |
|
|
@ -115,7 +115,7 @@ to the completion callback. |
|
|
|
|
|
|
|
Synchronous fchown(2). |
|
|
|
|
|
|
|
## fs.lchown(path, uid, gid, [callback]) |
|
|
|
## fs.lchown(path, uid, gid, callback) |
|
|
|
|
|
|
|
Asynchronous lchown(2). No arguments other than a possible exception are given |
|
|
|
to the completion callback. |
|
|
@ -124,7 +124,7 @@ to the completion callback. |
|
|
|
|
|
|
|
Synchronous lchown(2). |
|
|
|
|
|
|
|
## fs.chmod(path, mode, [callback]) |
|
|
|
## fs.chmod(path, mode, callback) |
|
|
|
|
|
|
|
Asynchronous chmod(2). No arguments other than a possible exception are given |
|
|
|
to the completion callback. |
|
|
@ -133,7 +133,7 @@ to the completion callback. |
|
|
|
|
|
|
|
Synchronous chmod(2). |
|
|
|
|
|
|
|
## fs.fchmod(fd, mode, [callback]) |
|
|
|
## fs.fchmod(fd, mode, callback) |
|
|
|
|
|
|
|
Asynchronous fchmod(2). No arguments other than a possible exception |
|
|
|
are given to the completion callback. |
|
|
@ -142,7 +142,7 @@ are given to the completion callback. |
|
|
|
|
|
|
|
Synchronous fchmod(2). |
|
|
|
|
|
|
|
## fs.lchmod(path, mode, [callback]) |
|
|
|
## fs.lchmod(path, mode, callback) |
|
|
|
|
|
|
|
Asynchronous lchmod(2). No arguments other than a possible exception |
|
|
|
are given to the completion callback. |
|
|
@ -153,20 +153,20 @@ Only available on Mac OS X. |
|
|
|
|
|
|
|
Synchronous lchmod(2). |
|
|
|
|
|
|
|
## fs.stat(path, [callback]) |
|
|
|
## fs.stat(path, callback) |
|
|
|
|
|
|
|
Asynchronous stat(2). The callback gets two arguments `(err, stats)` where |
|
|
|
`stats` is a [fs.Stats](#fs_class_fs_stats) object. See the [fs.Stats](#fs_class_fs_stats) |
|
|
|
section below for more information. |
|
|
|
|
|
|
|
## fs.lstat(path, [callback]) |
|
|
|
## fs.lstat(path, callback) |
|
|
|
|
|
|
|
Asynchronous lstat(2). The callback gets two arguments `(err, stats)` where |
|
|
|
`stats` is a `fs.Stats` object. `lstat()` is identical to `stat()`, except that if |
|
|
|
`path` is a symbolic link, then the link itself is stat-ed, not the file that it |
|
|
|
refers to. |
|
|
|
|
|
|
|
## fs.fstat(fd, [callback]) |
|
|
|
## fs.fstat(fd, callback) |
|
|
|
|
|
|
|
Asynchronous fstat(2). The callback gets two arguments `(err, stats)` where |
|
|
|
`stats` is a `fs.Stats` object. `fstat()` is identical to `stat()`, except that |
|
|
@ -184,7 +184,7 @@ Synchronous lstat(2). Returns an instance of `fs.Stats`. |
|
|
|
|
|
|
|
Synchronous fstat(2). Returns an instance of `fs.Stats`. |
|
|
|
|
|
|
|
## fs.link(srcpath, dstpath, [callback]) |
|
|
|
## fs.link(srcpath, dstpath, callback) |
|
|
|
|
|
|
|
Asynchronous link(2). No arguments other than a possible exception are given to |
|
|
|
the completion callback. |
|
|
@ -193,7 +193,7 @@ the completion callback. |
|
|
|
|
|
|
|
Synchronous link(2). |
|
|
|
|
|
|
|
## fs.symlink(srcpath, dstpath, [type], [callback]) |
|
|
|
## fs.symlink(srcpath, dstpath, [type], callback) |
|
|
|
|
|
|
|
Asynchronous symlink(2). No arguments other than a possible exception are given |
|
|
|
to the completion callback. |
|
|
@ -206,7 +206,7 @@ Note that Windows junction points require the destination path to be absolute. |
|
|
|
|
|
|
|
Synchronous symlink(2). |
|
|
|
|
|
|
|
## fs.readlink(path, [callback]) |
|
|
|
## fs.readlink(path, callback) |
|
|
|
|
|
|
|
Asynchronous readlink(2). The callback gets two arguments `(err, |
|
|
|
linkString)`. |
|
|
@ -234,7 +234,7 @@ Example: |
|
|
|
|
|
|
|
Synchronous realpath(2). Returns the resolved path. |
|
|
|
|
|
|
|
## fs.unlink(path, [callback]) |
|
|
|
## fs.unlink(path, callback) |
|
|
|
|
|
|
|
Asynchronous unlink(2). No arguments other than a possible exception are given |
|
|
|
to the completion callback. |
|
|
@ -243,7 +243,7 @@ to the completion callback. |
|
|
|
|
|
|
|
Synchronous unlink(2). |
|
|
|
|
|
|
|
## fs.rmdir(path, [callback]) |
|
|
|
## fs.rmdir(path, callback) |
|
|
|
|
|
|
|
Asynchronous rmdir(2). No arguments other than a possible exception are given |
|
|
|
to the completion callback. |
|
|
@ -252,7 +252,7 @@ to the completion callback. |
|
|
|
|
|
|
|
Synchronous rmdir(2). |
|
|
|
|
|
|
|
## fs.mkdir(path, [mode], [callback]) |
|
|
|
## fs.mkdir(path, [mode], callback) |
|
|
|
|
|
|
|
Asynchronous mkdir(2). No arguments other than a possible exception are given |
|
|
|
to the completion callback. `mode` defaults to `0777`. |
|
|
@ -261,7 +261,7 @@ to the completion callback. `mode` defaults to `0777`. |
|
|
|
|
|
|
|
Synchronous mkdir(2). |
|
|
|
|
|
|
|
## fs.readdir(path, [callback]) |
|
|
|
## 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 |
|
|
@ -272,7 +272,7 @@ the names of the files in the directory excluding `'.'` and `'..'`. |
|
|
|
Synchronous readdir(3). Returns an array of filenames excluding `'.'` and |
|
|
|
`'..'`. |
|
|
|
|
|
|
|
## fs.close(fd, [callback]) |
|
|
|
## fs.close(fd, callback) |
|
|
|
|
|
|
|
Asynchronous close(2). No arguments other than a possible exception are given |
|
|
|
to the completion callback. |
|
|
@ -281,7 +281,7 @@ to the completion callback. |
|
|
|
|
|
|
|
Synchronous close(2). |
|
|
|
|
|
|
|
## fs.open(path, flags, [mode], [callback]) |
|
|
|
## fs.open(path, flags, [mode], callback) |
|
|
|
|
|
|
|
Asynchronous file open. See open(2). `flags` can be: |
|
|
|
|
|
|
@ -334,18 +334,18 @@ not followed. Exclusive mode may or may not work with network file systems. |
|
|
|
|
|
|
|
Synchronous open(2). |
|
|
|
|
|
|
|
## fs.utimes(path, atime, mtime, [callback]) |
|
|
|
## fs.utimes(path, atime, mtime, callback) |
|
|
|
## fs.utimesSync(path, atime, mtime) |
|
|
|
|
|
|
|
Change file timestamps of the file referenced by the supplied path. |
|
|
|
|
|
|
|
## fs.futimes(fd, atime, mtime, [callback]) |
|
|
|
## fs.futimes(fd, atime, mtime, callback) |
|
|
|
## fs.futimesSync(fd, atime, mtime) |
|
|
|
|
|
|
|
Change the file timestamps of a file referenced by the supplied file |
|
|
|
descriptor. |
|
|
|
|
|
|
|
## fs.fsync(fd, [callback]) |
|
|
|
## fs.fsync(fd, callback) |
|
|
|
|
|
|
|
Asynchronous fsync(2). No arguments other than a possible exception are given |
|
|
|
to the completion callback. |
|
|
@ -354,7 +354,7 @@ to the completion callback. |
|
|
|
|
|
|
|
Synchronous fsync(2). |
|
|
|
|
|
|
|
## fs.write(fd, buffer, offset, length, position, [callback]) |
|
|
|
## fs.write(fd, buffer, offset, length, position, callback) |
|
|
|
|
|
|
|
Write `buffer` to the file specified by `fd`. |
|
|
|
|
|
|
@ -376,7 +376,7 @@ without waiting for the callback. For this scenario, |
|
|
|
|
|
|
|
Synchronous version of `fs.write()`. Returns the number of bytes written. |
|
|
|
|
|
|
|
## fs.read(fd, buffer, offset, length, position, [callback]) |
|
|
|
## fs.read(fd, buffer, offset, length, position, callback) |
|
|
|
|
|
|
|
Read data from the file specified by `fd`. |
|
|
|
|
|
|
@ -395,12 +395,13 @@ The callback is given the three arguments, `(err, bytesRead, buffer)`. |
|
|
|
|
|
|
|
Synchronous version of `fs.read`. Returns the number of `bytesRead`. |
|
|
|
|
|
|
|
## fs.readFile(filename, [options], [callback]) |
|
|
|
## fs.readFile(filename, [options], callback) |
|
|
|
|
|
|
|
* `filename` {String} |
|
|
|
* `options` {Object} |
|
|
|
* `encoding` {String | Null} default = `null` |
|
|
|
* `flag` {String} default = `'r'` |
|
|
|
* `callback` {Function} |
|
|
|
|
|
|
|
Asynchronously reads the entire contents of a file. Example: |
|
|
|
|
|
|
@ -423,7 +424,7 @@ If the `encoding` option is specified then this function returns a |
|
|
|
string. Otherwise it returns a buffer. |
|
|
|
|
|
|
|
|
|
|
|
## fs.writeFile(filename, data, [options], [callback]) |
|
|
|
## fs.writeFile(filename, data, [options], callback) |
|
|
|
|
|
|
|
* `filename` {String} |
|
|
|
* `data` {String | Buffer} |
|
|
@ -431,6 +432,7 @@ string. Otherwise it returns a buffer. |
|
|
|
* `encoding` {String | Null} default = `'utf8'` |
|
|
|
* `mode` {Number} default = `438` (aka `0666` in Octal) |
|
|
|
* `flag` {String} default = `'w'` |
|
|
|
* `callback` {Function} |
|
|
|
|
|
|
|
Asynchronously writes data to a file, replacing the file if it already exists. |
|
|
|
`data` can be a string or a buffer. |
|
|
@ -449,7 +451,7 @@ Example: |
|
|
|
|
|
|
|
The synchronous version of `fs.writeFile`. |
|
|
|
|
|
|
|
## fs.appendFile(filename, data, [options], [callback]) |
|
|
|
## fs.appendFile(filename, data, [options], callback) |
|
|
|
|
|
|
|
* `filename` {String} |
|
|
|
* `data` {String | Buffer} |
|
|
@ -457,6 +459,7 @@ The synchronous version of `fs.writeFile`. |
|
|
|
* `encoding` {String | Null} default = `'utf8'` |
|
|
|
* `mode` {Number} default = `438` (aka `0666` in Octal) |
|
|
|
* `flag` {String} default = `'a'` |
|
|
|
* `callback` {Function} |
|
|
|
|
|
|
|
Asynchronously append data to a file, creating the file if it not yet exists. |
|
|
|
`data` can be a string or a buffer. |
|
|
@ -571,7 +574,7 @@ callback, and have some fallback logic if it is null. |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
## fs.exists(path, [callback]) |
|
|
|
## fs.exists(path, callback) |
|
|
|
|
|
|
|
Test whether or not the given path exists by checking with the file system. |
|
|
|
Then call the `callback` argument with either true or false. Example: |
|
|
|