|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
File I/O is provided by simple wrappers around standard POSIX functions. To |
|
|
|
use this module do `require('fs')`. All the methods have asynchronous and |
|
|
|
synchronous forms. |
|
|
|
synchronous forms. |
|
|
|
|
|
|
|
The asynchronous form always take a completion callback as its last argument. |
|
|
|
The arguments passed to the completion callback depend on the method, but the |
|
|
@ -54,7 +54,7 @@ the entire process until they complete--halting all connections. |
|
|
|
|
|
|
|
### fs.rename(path1, path2, [callback]) |
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
### fs.renameSync(path1, path2) |
|
|
@ -63,7 +63,7 @@ Synchronous rename(2). |
|
|
|
|
|
|
|
### fs.truncate(fd, len, [callback]) |
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
### fs.truncateSync(fd, len) |
|
|
@ -72,16 +72,16 @@ Synchronous ftruncate(2). |
|
|
|
|
|
|
|
### fs.chmod(path, mode, [callback]) |
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
### fs.chmodSync(path, mode) |
|
|
|
|
|
|
|
Synchronous chmod(2). |
|
|
|
|
|
|
|
|
|
|
|
### fs.stat(path, [callback]) |
|
|
|
|
|
|
|
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. It looks like this: |
|
|
|
|
|
|
|
{ dev: 2049, |
|
|
@ -102,14 +102,14 @@ See the `fs.Stats` section below for more information. |
|
|
|
|
|
|
|
### 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 |
|
|
|
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]) |
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
### fs.statSync(path) |
|
|
@ -126,7 +126,7 @@ Synchronous fstat(2). Returns an instance of `fs.Stats`. |
|
|
|
|
|
|
|
### fs.link(srcpath, dstpath, [callback]) |
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
### fs.linkSync(dstpath, srcpath) |
|
|
@ -135,7 +135,7 @@ Synchronous link(2). |
|
|
|
|
|
|
|
### fs.symlink(linkdata, path, [callback]) |
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
### fs.symlinkSync(linkdata, path) |
|
|
@ -144,8 +144,8 @@ Synchronous symlink(2). |
|
|
|
|
|
|
|
### fs.readlink(path, [callback]) |
|
|
|
|
|
|
|
Asynchronous readlink(2). The callback gets two arguments `(err, |
|
|
|
resolvedPath)`. |
|
|
|
Asynchronous readlink(2). The callback gets two arguments `(err, |
|
|
|
resolvedPath)`. |
|
|
|
|
|
|
|
### fs.readlinkSync(path) |
|
|
|
|
|
|
@ -153,7 +153,7 @@ Synchronous readlink(2). Returns the resolved path. |
|
|
|
|
|
|
|
### fs.realpath(path, [callback]) |
|
|
|
|
|
|
|
Asynchronous realpath(2). The callback gets two arguments `(err, |
|
|
|
Asynchronous realpath(2). The callback gets two arguments `(err, |
|
|
|
resolvedPath)`. |
|
|
|
|
|
|
|
### fs.realpathSync(path) |
|
|
@ -162,7 +162,7 @@ Synchronous realpath(2). Returns the resolved path. |
|
|
|
|
|
|
|
### fs.unlink(path, [callback]) |
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
### fs.unlinkSync(path) |
|
|
@ -171,7 +171,7 @@ Synchronous unlink(2). |
|
|
|
|
|
|
|
### fs.rmdir(path, [callback]) |
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
### fs.rmdirSync(path) |
|
|
@ -180,7 +180,7 @@ Synchronous rmdir(2). |
|
|
|
|
|
|
|
### fs.mkdir(path, mode, [callback]) |
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
### fs.mkdirSync(path, mode) |
|
|
@ -200,7 +200,7 @@ Synchronous readdir(3). Returns an array of filenames excluding `'.'` and |
|
|
|
|
|
|
|
### fs.close(fd, [callback]) |
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
### fs.closeSync(fd) |
|
|
@ -210,11 +210,11 @@ Synchronous close(2). |
|
|
|
### fs.open(path, flags, mode=0666, [callback]) |
|
|
|
|
|
|
|
Asynchronous file open. See open(2). Flags can be 'r', 'r+', 'w', 'w+', 'a', |
|
|
|
or 'a+'. The callback gets two arguments `(err, fd)`. |
|
|
|
or 'a+'. The callback gets two arguments `(err, fd)`. |
|
|
|
|
|
|
|
### fs.openSync(path, flags, mode=0666) |
|
|
|
|
|
|
|
Synchronous open(2). |
|
|
|
Synchronous open(2). |
|
|
|
|
|
|
|
### fs.write(fd, buffer, offset, length, position, [callback]) |
|
|
|
|
|
|
@ -232,12 +232,12 @@ specifies how many _bytes_ were written. |
|
|
|
|
|
|
|
### fs.writeSync(fd, buffer, offset, length, position) |
|
|
|
|
|
|
|
Synchronous version of buffer-based `fs.write()`. Returns the number of bytes |
|
|
|
Synchronous version of buffer-based `fs.write()`. Returns the number of bytes |
|
|
|
written. |
|
|
|
|
|
|
|
### fs.writeSync(fd, str, position, encoding='utf8') |
|
|
|
|
|
|
|
Synchronous version of string-based `fs.write()`. Returns the number of bytes |
|
|
|
Synchronous version of string-based `fs.write()`. Returns the number of bytes |
|
|
|
written. |
|
|
|
|
|
|
|
### fs.read(fd, buffer, offset, length, position, [callback]) |
|
|
@ -257,12 +257,12 @@ The callback is given the two arguments, `(err, bytesRead)`. |
|
|
|
|
|
|
|
### fs.readSync(fd, buffer, offset, length, position) |
|
|
|
|
|
|
|
Synchronous version of buffer-based `fs.read`. Returns the number of |
|
|
|
Synchronous version of buffer-based `fs.read`. Returns the number of |
|
|
|
`bytesRead`. |
|
|
|
|
|
|
|
### fs.readSync(fd, length, position, encoding) |
|
|
|
|
|
|
|
Synchronous version of string-based `fs.read`. Returns the number of |
|
|
|
Synchronous version of string-based `fs.read`. Returns the number of |
|
|
|
`bytesRead`. |
|
|
|
|
|
|
|
### fs.readFile(filename, [encoding], [callback]) |
|
|
@ -320,7 +320,7 @@ stat object: |
|
|
|
console.log('the previous mtime was: ' + prev.mtime); |
|
|
|
}); |
|
|
|
|
|
|
|
These stat objects are instances of `fs.Stat`. |
|
|
|
These stat objects are instances of `fs.Stat`. |
|
|
|
|
|
|
|
### fs.unwatchFile(filename) |
|
|
|
|
|
|
|