Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I programmatically distinguish hard links from real files in 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?

like image 926
SKINDER Avatar asked Sep 12 '25 02:09

SKINDER


1 Answers

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...)

Use the builtin methods Windows provides for calculating used space instead.

EDIT: Reference (emphasis mine)

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.

like image 114
Billy ONeal Avatar answered Sep 13 '25 16:09

Billy ONeal