Hard links - detecting their presence

Jun 7, 2008
121
0
#1
Hi

How do I know if a file is a hard link?
It does not seem detectable in TCC
Neither ATTRIB nor a DIR switch seems to show up anything.

Thanks

Stephen Howe
 

dim

Dimitry Andric
May 31, 2008
204
1
Netherlands
#2
How do I know if a file is a hard link?
It does not seem detectable in TCC
Neither ATTRIB nor a DIR switch seems to show up anything.
You cannot find out (easily) which other links a certain file has, but it is easy to see if two (or more) files are hard linked together, using the @INODE function:

Code:
D:\Tmp>echo foo > foo

D:\Tmp>mklnk foo bar
D:\Tmp\bar -> D:\Tmp\foo

D:\Tmp>dir foo bar
2009-05-06  20:28               5  foo
2009-05-06  20:28               5  bar

D:\Tmp>echo %@inode[foo] %@inode[bar]
00500000:000DAD6E 00500000:000DAD6E

D:\Tmp>if %@inode[foo]==%@inode[bar] echo foo and bar are the same file
foo and bar are the same file
 
#3
dim wrote:
| ---Quote (Originally by Stephen Howe)---
| How do I know if a file is a hard link?
| It does not seem detectable in TCC
| Neither ATTRIB nor a DIR switch seems to show up anything.
| ---End Quote---
| You cannot find out (easily) which other links a certain file has,
| but it is easy to see if two (or more) files are hard linked
| together, using the @INODE function:
...

and the @links[] function tells you how many directory entries exist for the
file (i.e., it can be used to determine whether or not any other "file"
(i.e., directory entry) is hard linked the file of interest.
--
HTH, Steve