Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions doc/api/fs.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,14 @@ non-existent.

## fs.existsSync(path)

Stability: 0 - Deprecated: Use [fs.statSync][] or [fs.accessSync][] instead.

Synchronous version of [`fs.exists`][].
Returns `true` if the file exists, `false` otherwise.

Note: this function will throw on Windows if an EPERM error is returned by the
underlying `fs.statSync()` call. However, it is not suggested to attempt to
catch this error. Instead, the end user probably needs to fix the file's
permissions by hand.

## fs.fchmod(fd, mode, callback)

Asynchronous fchmod(2). No arguments other than a possible exception
Expand Down
3 changes: 3 additions & 0 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ fs.existsSync = function(path) {
binding.stat(pathModule._makeLong(path));
return true;
} catch (e) {
if (e.code === 'EPERM')
throw e; // EPERM means we no longer knows if it exists or not.

return false;
}
};
Expand Down