summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorYuval Brik <yuval@brik.org.il>2016-04-11 17:48:34 +0300
committerBrian White <mscdex@mscdex.net>2016-04-15 03:46:55 -0400
commitb488b19eaf2b2e7a3ca5eccd2445e245847a5f76 (patch)
tree51feaa7ff745bd5fcd686c1ed60bb4bc866acb62 /doc
parent81fd4581b922079cf059d336d44272c288ea8fdf (diff)
downloadandroid-node-v8-b488b19eaf2b2e7a3ca5eccd2445e245847a5f76.tar.gz
android-node-v8-b488b19eaf2b2e7a3ca5eccd2445e245847a5f76.tar.bz2
android-node-v8-b488b19eaf2b2e7a3ca5eccd2445e245847a5f76.zip
fs: optimize realpath using uv_fs_realpath()
Remove realpath() and realpathSync() cache. Use the native uv_fs_realpath() which is faster then the JS implementation by a few orders of magnitude. PR-URL: https://github.com/nodejs/node/pull/3594 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/fs.markdown36
1 files changed, 17 insertions, 19 deletions
diff --git a/doc/api/fs.markdown b/doc/api/fs.markdown
index 6fdea6f7f0..fc2dd5934e 100644
--- a/doc/api/fs.markdown
+++ b/doc/api/fs.markdown
@@ -916,26 +916,20 @@ object with an `encoding` property specifying the character encoding to use for
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.realpath(path[, cache], callback)
+## fs.realpath(path[, options], callback)
* `path` {String | Buffer}
-* `cache` {Object}
+* `options` {String | Object}
+ * `encoding` {String} default = `'utf8'`
* `callback` {Function}
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:
+resolvedPath)`. May use `process.cwd` to resolve relative paths.
-```js
-var cache = {'/etc':'/private/etc'};
-fs.realpath('/etc/passwd', cache, (err, resolvedPath) => {
- if (err) throw err;
- console.log(resolvedPath);
-});
-```
+The optional `options` argument can be a string specifying an encoding, or an
+object with an `encoding` property specifying the character encoding to use for
+the path passed to the callback. If the `encoding` is set to `'buffer'`,
+the path returned will be passed as a `Buffer` object.
## fs.readSync(fd, buffer, offset, length, position)
@@ -947,14 +941,18 @@ fs.realpath('/etc/passwd', cache, (err, resolvedPath) => {
Synchronous version of [`fs.read()`][]. Returns the number of `bytesRead`.
-## fs.realpathSync(path[, cache])
+## fs.realpathSync(path[, options])
* `path` {String | Buffer};
-* `cache` {Object}
+* `options` {String | Object}
+ * `encoding` {String} default = `'utf8'`
-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.
+Synchronous realpath(2). Returns the resolved path.
+
+The optional `options` argument can be a string specifying an encoding, or an
+object with an `encoding` property specifying the character encoding to use for
+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)