Optional
mode: numberSynchronously tests a user's permissions for the file or directory specified
by path
. The mode
argument is an optional integer that specifies the
accessibility checks to be performed. Check File access constants
for
possible values of mode
. It is possible to create a mask consisting of
the bitwise OR of two or more values
(e.g. fs.constants.W_OK | fs.constants.R_OK
).
If any of the accessibility checks fail, an Error
will be thrown. Otherwise,
the method will return undefined
.
import { accessSync, constants } from 'fs';
try {
accessSync('etc/passwd', constants.R_OK | constants.W_OK);
console.log('can read/write');
} catch (err) {
console.error('no access!');
}
v0.0.67
Optional
mode: numberGenerated using TypeDoc
Synchronously tests a user's permissions for the file or directory specified by
path
. Themode
argument is an optional integer that specifies the accessibility checks to be performed. CheckFile access constants
for possible values ofmode
. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g.fs.constants.W_OK | fs.constants.R_OK
).If any of the accessibility checks fail, an
Error
will be thrown. Otherwise, the method will returnundefined
.Since
v0.0.67