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.read- 文件系统读取操作fs.write- 文件系统写入操作child- 子进程生成操作worker- 工作线程生成操作
// 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');