Page 1 of 1

Hard Links

Posted: 23 Nov 2011 23:04
by xp10
I've made an almost incredible experience; I didn't believe my eyes; I checked and counterchecked; these are facts:

In order to realize a filing system with hundreds of files within the same directory, I created hard links for many of them. (I'll publish the system here when I'll have got some more hints how to do things right.)

I created them within XY by doing a control-c of these files, then doing the command Edit - Paste Special - Paste as Hard Link(s), then renaming them, e.g.

original file abc.xy
hardlink created by XY abc-01.xy
renamed by me to de.abc.xy

All this in XY, all this within the same folder, and my system is XP3.

Now, it's understood that hard links just POINT to the original file, i.e. when you click on such a hard link in order to open the file, the original file will be opened, of course, not any COPY of that file.

I opened original files ( abc.xy ), worked on them, closed them.

I did the same by opening hard links ( clicking on de.abc.xy ), thinking to open the original files by this, working on them, closing them down...

I wanted to be sure. So I made changes to such a file, opened by clicking on the hard link, then closing it. Then I clicked on the original file: THE CHANGES WEREN'T THERE! I clicked again on the hard link: The changes had been very well saved!

There cannot be but one explanation to this incredible phenomenon as far as I'm concerned, at this time:

XY seems to make COPIES of files instead of doing hard links!

Of course, this could be a general behavior of the XY command, or it could be possible that this behavior only affects some (exotic) file formats, but anyway, this may not be.

Can you please check and comment?

EDIT: Of course, the directory in question is c:\1\, = main hard disk, NTFS-formatted, no FAT or something, and I did NOT have open original file and hardlink file at the same time, thus no hardlink opening counter interference or something possible. Of course, the hard link entries in the XY list show the same size as the original files, but I originally thought thas was because they "stand for" these - if they are copies of the original files, it would not be astonishing either that they have got the same size as the originals, then...

EDIT 2: Don't tell me if I rename a hard link, it becomes a copy by this? That it's allowed to rename the original file name, but not the hard link? That might be a possible explanation, but then, in the web, I haven't found any hint to such problems.

Re: Hard Links

Posted: 23 Nov 2011 23:40
by PeterH
Did almost the same - just other way, what should make no difference.
Result: changing contents on one of the names results in change of both - i.e. for me both names point to the same file!

My sequence:
- right-click file / Copy
- right-click empty space / Paste Special / Paste as Hardlink
- rename as you did

Re: Hard Links

Posted: 23 Nov 2011 23:57
by xp10
Peter, that's why I said I couldn't believe my eyes.

Some problems arise from exotic file formats while all those ubiquitous MS / Adobe / etc. files are not affected, but then, I suppose hard linking is file system internals, i.e. Windows stuff, whilst "what sort of file" it is shouldn't matter as long as it is a Windows-compatible file; I want to say, if a file can be handled by the Windows file system, and is from a Windows application, the standard file management commands should work on them in equal way - or what special conditions WITHIN the file format of the application must be met then for the hard linking to function faultlessly?

And I LOVE these posts, "I don't have your problem" - no pun intended, but they are truly devastating.

BTW, do your hard links show just some bytes, or multi-k sizes like the "original" entries of the original files do?

EDIT: Of course, tomorrow, I'll have to do lots of hardlinks, renames of hardlinks, working within those files launched by original, and by hard link entry, checking for those changes made here and there, within the other version... it's probably a file format problem, in the end, so I hope that .lnk files will work with which of course I could replace my hard links.

I begin to have remorses upon my purchase ; as said, those "I don't have your problem" posts are devastating, really.

Re: Hard Links

Posted: 24 Nov 2011 00:35
by PeterH
Basically we have the same expectation: this is one file with 2 names.
And I'm convinced: the name, type or contents of file doesn't matter.

So I created an empty abc.xy, edited it to some lines, then created hardlink. Then changed one, checked the other, and then vice versa.

As I've deleted all after that, I just recreated it, with some more lines in abc.xy. (Copy/paste a line several times.) Then created the hardlink => both showed size=10KB.
Now added lines to de.abc.xy and saved - this now was shown as 14KB.
But (thanks God) after just a click on abc.xy it updated to 14KB as well - just a little refresh problem.
Preview of the files is identical.

To verify I added lines to abc.xy again: as expected the same as before - now 19KB for both.

By the way: (after a click to the not-changed name for refresh) *both* names show the same changed-time - again "as expected".

So for me everything seems to be as it should...

Re: Hard Links

Posted: 24 Nov 2011 07:03
by j_c_hallgren
xp10 wrote:And I LOVE these posts, "I don't have your problem" - no pun intended, but they are truly devastating.

I begin to have remorses upon my purchase ; as said, those "I don't have your problem" posts are devastating, really.
Well, just because someone else who has a similar setup doesn't encounter the problem you're having doesn't mean the issue doesn't exist but rather just that it's not a shared common problem that affects all users as most bugs do...there have been many times when only one user has a problem and Don has found a bug but most often, it's not XY but something else unique to that user's system causing it.

Re: Hard Links

Posted: 25 Nov 2011 13:40
by Brother John
Hard links cannot cross volume boundaries, i.e. they must stay within the same drive or NTFS mount point. Might that be the reason?

Re: Hard Links

Posted: 25 Nov 2011 14:09
by PeterH
Brother John wrote:Hard links cannot cross volume boundaries, i.e. they must stay within the same drive or NTFS mount point. Might that be the reason?
From the way he made the question I assumed that he even used the same directory. But I might be wrong?
Reason: the hardlink he created seemed automatically renamed - so it seems to be a local double of the original name.

Re: Hard Links

Posted: 25 Nov 2011 18:35
by Brother John
@PeterH
Originally I assumed he created the links in a different subfolder of C:\1 – just the way I usually create hardlinks I guess. And that could be on another disk. For example my D: drive folder structure consists of up to four physical hard disks. On second all seems to happen in C:\1.

@xp10
I checked now with XY 10.6 and Windows 7 and XP SP3. No problems at all. “Copy to clipboard -> paste as hardlink” always works as expected. It doesn’t matter if the hardlink or the original (technically speaking there is no “original” anyway) has a different name than the original. Editing one instance always affects all instances.

Re: Hard Links

Posted: 25 Nov 2011 21:34
by PeterH
Simple idea, as I tested one thing: I also tested the other :roll:

So I tried to create a hardlink of one file on another drive.

XY said:
Create Hard Link Failed
Different drive. Target has to be on the same drive.


Also this is what should be expected 8)

Re: Hard Links

Posted: 27 Nov 2011 10:07
by xp10
Thank you very much everybody for your trying to help, very appreciated.

As said, I created the "hardlinks" in the same directory (which by definition is on the same drive, and in my case, as stated, on my main drive c:, formatted NationalHealthSystem or something).

I was very pleased by these "hardlinks" since they showed the comments I had given to the original files - for any expert, that would have said it all, then.

Browse the web for two hours, you will NOT get reliable, comprehensive information about hardlinks, so I've learned here (the term "hardlink" meaning a copy of which your file commander thinks it just created a hardlink):

- If your "hardlink" shows the same comment as your original file, you didn't create a hardlink but a copy - even if XY does not present a message, "instead of creating a hardlink, the "create a hardlink" command you just applied created a copy instead". The other way round, XY seems to create a hardlink and does not inform you that you didn't. Call that a bug if you like.

- Same bug in xplorer2: Also creates copy instead of hardlink and remains silent about the unfruitful command execution.

- Thus, hardlinks do NOT show the original's comments but their own if any, let alone any synchronization of those comments back and / or forth.

- For MOST MS Windows file formats, the XY "paste hardlink" command creates a hardlink, as you correctly stated, on my system as on yours.

- Renaming doesn't affect the correct behavior of hardlinks, neither renaming of the original file nor renaming of the hardlink (if done in your file manager; if you do "save as" commands in your applics, I don't know but fear you could be up for surprises).

- Creating the hardlinks or "hardlinks" within the same folder or another (sub or sibling or any, on the same drive) doesn't make any difference; the only difference I see here between XY and X2 is that XY automatically renames the hardlink and "hardlink" if you create it within the same folder, while X2 refuses to create a hardlink or "hardlink" within the same folder, so if you want it to be within the same folder, with X2 you could create it in another folder (perhaps a sub), then rename it there, then move it to the original folder.

- SHORTCUTS (!) do not preserve the comments of the original files, but neither do hardlinks, as seen; the seemingly preservation of such comments in hardlinks, in fact "hardlinks", made me chose them over SHORTCUTS in the first place.

- For SOME MS Windows file formats, that hardlink creation, instead of being aborted by your file commander, with corresponding message, "not possible" or something, triggers creation of a copy instead, without user being informed in any way. This behavior isn't aleatoric but replicable, for special file formats, i.e. for every such file of that format, a copy instead of a hardlink is created (and, as stated above, without the renaming and / or folder being the same / another one having their hands in this).

- Finally, here's my treacherous file format, but beware some of your formats could behave that way: .ao files, from ActionOutline (I've got hundreds of them, but as said, hardlinks do not preserve the original's comments either, so reverting to SHORTCUTS (which work fine even with AO) isn't any additional usability loss).

- Thus, whatever its name and with exotic file formats, your file manager might not be as reliable as you're eager to think.

IMPORTANT EDIT: I now mixed up symbolic links (seemingly possible from Vista on, thus correctly greyed out in my XY menu) with SHORTCUTS (in German: "Verknüpfungen"); thus, in this post, wherever I spoke of symbolic links, I replaced that erroneous term by the correct term of shortcut - I always meant that, the thing with the .lnk ending and the little arrow within the symbol. (Then we have junctions, some other links, etc., etc. - ONE such a thing, but functioning without fault and with updated comments here and there, would have done, but that would have been too much to ask from MS.)