Function accessSync

  • Synchronously 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!');
    }

    Since

    v0.0.67

    Parameters

    • path: PathLike
    • Optional mode: number

    Returns void

  • Synchronously 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!');
    }

    Since

    v0.0.67

    Parameters

    • path: PathLike
    • Optional mode: number

    Returns void

Generated using TypeDoc