process.permission.has(scope[, reference])


验证进程是否能够访问给定的范围和引用。如果未提供引用,则假定为全局作用域,例如,process.permission.has('fs.read') 将检查进程是否具有所有文件系统读取权限。

¥Verifies that the process is able to access the given scope and reference. If no reference is provided, a global scope is assumed, for instance, process.permission.has('fs.read') will check if the process has ALL file system read permissions.

引用具有基于所提供范围的含义。例如,范围为文件系统时的引用表示文件和文件夹。

¥The reference has a meaning based on the provided scope. For example, the reference when the scope is File System means files and folders.

可用的范围是:

¥The available scopes are:

  • fs - 所有文件系统

    ¥fs - All File System

  • fs.read - 文件系统读取操作

    ¥fs.read - File System read operations

  • fs.write - 文件系统写操作

    ¥fs.write - File System write operations

  • child - 子进程生成操作

    ¥child - Child process spawning operations

  • worker - 工作线程生成操作

    ¥worker - Worker thread spawning operation

// Check if the process has permission to read the README file
process.permission.has('fs.read', './README.md');
// Check if the process has read permission operations
process.permission.has('fs.read');