From b0ae0f9920ca01c89782a440ad65e3c99d378d98 Mon Sep 17 00:00:00 2001 From: Dan Fabulich Date: Wed, 9 Dec 2015 13:50:34 -0800 Subject: [PATCH] fs: add accessibleSync() which returns a boolean As opposed to accessSync() which does nothing or throws --- doc/api/fs.md | 6 ++++++ lib/fs.js | 11 +++++++++++ src/node_file.cc | 26 ++++++++++++++++++++++++++ test/parallel/test-fs-access.js | 5 +++++ 4 files changed, 48 insertions(+) diff --git a/doc/api/fs.md b/doc/api/fs.md index 022fa0d2cf2732..4a2e93ed4bef8a 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -345,6 +345,12 @@ added: v0.11.15 Synchronous version of [`fs.access()`][]. This throws if any accessibility checks fail, and does nothing otherwise. +## fs.accessibleSync(path[, mode]) + +Returns false if any accessibility checks fail, and returns true otherwise. +This version is faster and more convenient to use than [`fs.accessSync()`][] +if you don't need to know why the file is not accessible. + ## fs.appendFile(file, data[, options], callback)