#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    India
    Posts
    178
    Rep Power
    26

    How to check hard links and symbolic links on Windows?


    How to check hard link and symbolic links on windows platform?

    Tried using stat(), lstat() etc but its not working corectly on windows!

    Also tried if(-l $file), readlink() etc, they are not working on windows, at least could not figure out how to use them!

    Specifically, want to figure out if given entry is file, directory, symbolic link or hard link. ON WINDOWS!

    Thanks
    ~Narendra
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2011
    Posts
    46
    Rep Power
    62
    You can use -f to see if its a file, -d to see if its a directory.

    I don't think windows filesystems have the concept of symbolic or hard links so can't check for them which is why stat,lstat etc aren't doing what you expect.
  4. #3
  5. Backwards Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,921
    Rep Power
    9646
    A symbolic link is just a *.LNK file, so -f and /\.lnk$/i.

    For hardlinks, on the filesystems that support them (like NTFS), it doesn't seem like there's a pure Perl answer. Most of what I've seen says to grep a `dir` output for the string "<JUNCTION>".

IMN logo majestic logo threadwatch logo seochat tools logo