I know how I can find out whether a file has hard-link siblings (link), but how can I get the paths of the (other) files when I have one?
Asked
Active
Viewed 138 times
0
-
Hardly, there's no Java API. You could look at i-node number, which is shared by all hard-links. Unfortunately, filesystem does not save map i-node to filepath, so the only way is to traverse filesystem by yourself and stop till you find them all. – hradecek Nov 16 '20 at 14:43
1 Answers
1
The OS doesn't provide a way to do this efficiently. What you need to do is to traverse the file system and look for all file entries with the same inode number as the one you already have.
You would do it the same way in Java.
(This Q&A explains how to get the inode number for a file in Java: Uniquely identify file in Java)

Stephen C
- 698,415
- 94
- 811
- 1,216