c++ - 如何以编程方式区分 Windows 7 中的硬链接(hard link)和真实文件?

标签 c++ windows-7 hardlink

我在文件大小和已用磁盘空间之间存在差异(总文件大小甚至超过磁盘大小)。我想是因为 Windows 7/Vista 中存在许多硬链接(hard link)(到 WinSxS 组件)。但是在 Windows 7 中如何以编程方式区分硬链接(hard link)和真实文件?

最佳答案

你不能,因为所有文件都是硬链接(hard link)。不完全是。文件只是指向数据 block 的硬链接(hard link)——目录中的列表。 (也许你的意思是符号链接(symbolic link)?你可以区分它们...)

改为使用 Windows 提供的内置方法来计算已用空间。

编辑:Reference (强调我的)

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.

关于c++ - 如何以编程方式区分 Windows 7 中的硬链接(hard link)和真实文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3636820/

相关文章:

shell - 通过 shell 脚本查找不是*硬链接(hard link)的文件

c++ - 批量分配库

windows-7 - Windows7 中的 "gdb.exe has stopped working "

具有窗口捕捉功能的 Linux 应用程序或发行版(如 Windows 7)

windows-7 - 在 Win7 上 GetOpenFileName 函数忽略 lpstr InitialDir 参数

c - 查找某个文件的所有硬链接(hard link)

linux - 删除文件后保持硬链接(hard link)连接

c++ - 在函数调用时从异构初始化列表构建元组

c++ - 将文字分配给指针

c++ - 用 less 子句结构聚合初始化,为什么它初始化所有东西?