diff --git a/lib/fs.js b/lib/fs.js index 0a5a5247607d1d..5d3bae1550e298 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -323,12 +323,7 @@ fs.accessSync = function(path, mode) { }; fs.exists = function(path, callback) { - if (handleError((path = getPathFromURL(path)), cb)) - return; - if (!nullCheck(path, cb)) return; - var req = new FSReqWrap(); - req.oncomplete = cb; - binding.stat(pathModule.toNamespacedPath(path), req); + fs.access(path, fs.F_OK, cb); function cb(err) { if (callback) callback(err ? false : true); } @@ -345,9 +340,7 @@ Object.defineProperty(fs.exists, internalUtil.promisify.custom, { fs.existsSync = function(path) { try { - handleError((path = getPathFromURL(path))); - nullCheck(path); - binding.stat(pathModule.toNamespacedPath(path)); + fs.accessSync(path, fs.F_OK); return true; } catch (e) { return false;