How to find all the hard and symbolic links to a file/folder in Windows (using standard OS functions)?
What is opposed to UNIX?
How to find all the hard and symbolic links to a file/folder in Windows (using standard OS functions)?
What is opposed to UNIX?
From this nice tutorial for linux:
https://jackal.livejournal.com/2164247.html
Get the inode number:
ls -i FILENAME
Find file by inode number:
find / -inum INODE-NUM-FROM-ABOVE
Optionally restrict find
to speed up the search.
Example:
> ls -i myfile.csv
74714625 myfile.csv
> find ~/myfolder/ -inum 74714625
/home/me/myfolder/myfile.csv
/home/me/myfolder/another/path/another_filename_with_same_inode.csv
Symlinks:
You´ll have to search all files on all hard disks etc.etc. and check each of them individually. Otherwise it´s not possible to get a list of symlinks for a specific file.
For Linux, How do you determine using stat() whether a file is a symbolic link? may help.
For Windows ... well, Reparse points are not explainable in one line.
It´s not trivial to check if a file is a symlink from C++.
Hard links:
Linux: Again (usually) not possible without searching all files and checking the inode number.
Windows: Depending on the used file system, FindFirstFileName
and FindNextFileName
could be useful, but as said, they won´t always work (ReFS...)