gpt4 book ai didi

node.js - Nodejs - 文件属性和 POSIX ACL

转载 作者:太空宇宙 更新时间:2023-11-04 02:05:02 26 4
gpt4 key购买 nike

Nodejs 是否提供了任何或多或少的 native 方式来检查文件属性和 POSIX ACL?

我的意思是:

我认为第二个属性存储为扩展文件属性,并通过 C 级别的 getxattr/setxattr 设置/读取。

通过 native ,我的意思是没有通过 child_process 实际调用 setfacl/getfacl/chattr/lsattr 并解析 stdout。

最佳答案

Node.js 没有内置的调用 setxattr/getxattr 的方法。但是您可以使用一些 native 插件,例如https://github.com/LinusU/fs-xattr

npm install --save fs-xattr
const xattr = require('fs-xattr')
xattr.get("/path/to/file", "com.attr.name", (err, val) => {
if (err) throw err
console.log(`com.attr.name = ${val}`)
})

关于node.js - Nodejs - 文件属性和 POSIX ACL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44618167/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com