且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在OS X上使用node.js检测隐藏文件

更新时间:2023-02-12 09:49:48

inode编号( stats.ino )是唯一标识文件的编号.它与文件的隐藏状态无关.(实际上,可以随时设置或清除文件上的隐藏标志,这不会更改索引节点号.)

The inode number (stats.ino) is a number which uniquely identifies a file; it has nothing to do with the hidden status of the file. (Indeed, it's possible to set or clear the hidden flag on a file at any time, and this won't change the inode number.)

隐藏标志是 struct stat 结构中 st_flags 字段的一部分.不幸的是,它看起来不像node.js fs 模块公开了该值,因此,如果需要获取此值,则可能需要使用 stat shell实用程序有关Mac OS X的信息.(简短版本: stat -f%f file 将打印文件的标志,以十进制表示.)

The hidden flag is part of the st_flags field in the struct stat structure. Unfortunately, it doesn't look like the node.js fs module exposes this value, so you may need to shell out to the stat shell utility if you need to get this information on Mac OS X. (Short version: stat -f%f file will print a file's flags, represented in decimal.)