To see all hard links, send the file to a scrap container then use Tools > Find targets menu command.
So I have a "master" file and 4 shadow copies of it spread with hard linking. When I make changes to one file (it doesn't have to be the "original", any file will do) then the contents of the remaining 4 links are immediately updated. Unlike symbolic links, hard links are immune to relocations and renaming. Sweet!
Whilst magnificent in theory, the reality is that lots of programs destroy hard linkage when saving files. Paint.NET the editor I use to manage xplorer² skins is a culprit. If you modify and save one of the 5 X2SKIN.PNG files in our example, you will find that the new version has a link count of 1, and the rest drop down to 4; saving has messed up the connection, which defeats the purpose of using hard links in the first place!
Paint.NET uses an arcane "safe" save mechanism where it first saves to a temp file, deletes the original file if all is well, then renames the temp file with the original name — hence explaining the unlinking of the modified file
There is a workaround. If you know your editor is careless with hard links (Paint.NET, Visual studio, the list is long) follow these steps when you want to modify a file:
In this roundabout way, the link count will remain unmolested. Not perfect but a tolerable hassle if you only modify files infrequently. Alternatively, find another editor program that is link-friendly — or forget about hard links and use symbolic links for the "shadow copies" instead.
ps. the internal <F4> editor² is careful with hard links, so it's safe to edit text documents with it.
Post a comment on this topic »