From 08996fde3c08c0cfabc7cc3fe332d83f674ab099 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Wed, 27 Jul 2016 00:18:35 +0200 Subject: [PATCH] fs: restore JS implementation of realpath This reverts parts of https://github.com/nodejs/node/commit/b488b19eaf2b2e7a3ca5eccd2445e245847a5f76 restoring javascript implementation of realpath and realpathSync. Fixes: https://github.com/nodejs/node/issues/7175 Fixes: https://github.com/nodejs/node/issues/6861 Fixes: https://github.com/nodejs/node/issues/7294 Fixes: https://github.com/nodejs/node/issues/7192 Fixes: https://github.com/nodejs/node/issues/7044 Fixes: https://github.com/nodejs/node/issues/6624 Fixes: https://github.com/nodejs/node/issues/6978 PR-URL: https://github.com/nodejs/node/pull/7899 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- doc/api/fs.md | 8 +- lib/fs.js | 225 +++++++++++++++++- .../test-fs-realpath-buffer-encoding.js | 88 +++++++ .../test-fs-realpath-on-substed-drive.js | 53 +++++ 4 files changed, 360 insertions(+), 14 deletions(-) create mode 100644 test/parallel/test-fs-realpath-buffer-encoding.js create mode 100644 test/parallel/test-fs-realpath-on-substed-drive.js diff --git a/doc/api/fs.md b/doc/api/fs.md index ab8c8a92bdf..40b8a990631 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1222,6 +1222,8 @@ added: v0.1.31 Asynchronous realpath(3). The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd` to resolve relative paths. +Only paths that can be converted to UTF8 strings are supported. + 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'`, @@ -1238,10 +1240,12 @@ added: v0.1.31 Synchronous realpath(3). Returns the resolved path. +Only paths that can be converted to UTF8 strings are supported. + 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. +the returned value. If the `encoding` is set to `'buffer'`, the path returned +will be passed as a `Buffer` object. ## fs.rename(oldPath, newPath, callback)