如何在Windows 7中以编程方式将硬链接与实际文件区分开? [英] How can I programmatically distinguish hard links from real files in Windows 7?
问题描述
我在文件大小和已用磁盘空间之间有所区别(总文件大小甚至大于磁盘大小).我想是因为Windows 7/Vista中存在许多硬链接(到WinSxS组件).但是,如何在Windows 7中以编程方式将硬链接与实际文件区分开?
I have a difference between files size and used disk space (total file size is even more than disk size). I suppose because there are many hard links exist (to WinSxS components) in Windows 7/Vista. But how can I programmatically distinguish hard links from real files in Windows 7?
推荐答案
您不能,因为所有文件都是硬链接.不完全是.文件只是到数据块的硬链接-目录中的列表. (也许您是指符号链接?您可以区分那些...)
You can't, because all files are hard links. No. Really. A file is just a hard link to a data chunk -- a listing in a directory. (Perhaps you mean symlinks? You can distinguish those...)
使用Windows提供的内置方法来计算已用空间.
Use the builtin methods Windows provides for calculating used space instead.
参考(强调我的
链接本身只是一个目录条目,并且没有安全描述符.因此,当您更改硬链接的安全描述符时,即更改了基础文件的安全描述符,并且所有指向该文件的硬链接都允许新指定的访问.
The link itself is only a directory entry, and does not have a security descriptor. Therefore, when you change the security descriptor of a hard link, you a change the security descriptor of the underlying file, and all hard links that point to the file allow the newly specified access.
这篇关于如何在Windows 7中以编程方式将硬链接与实际文件区分开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!