1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Hard links - detecting their presence

Discussion in 'Support' started by Stephen Howe, May 6, 2009.

  1. Stephen Howe

    Joined:
    Jun 7, 2008
    Messages:
    121
    Likes Received:
    0
    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
     
  2. dim

    dim Dimitry Andric

    Joined:
    May 31, 2008
    Messages:
    203
    Likes Received:
    0
    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. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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
     

Share This Page