Well, as I said, this matter if fairly complicated and a considerable ammount of thought should be put into it. (Most likely the unix people and designers of other file and operating systems which have used hardlinks for ages already have.) Most likely, the correct answer is: It depends... (on the purpose and goal of the copy operation).
But as I said, my intention was not to copy the file anyway. I was expecting to get an overwrite warning/confirmation (just as if the files were not linked to each other or to any other file). My intention was to only copy nonexisting files. This behaviour was (would be) independent on the copy method used later on, should need for copying arise.
Petr Solin wrote:There are two variants for overwrite operation: open target file and write to it (links are not broken, currently used in Explorer and Salamander),
This is probably what I generaly would expect if the destination file is not linked to the source file, but to any other. In other situations, I would expect to get a completely independent file (i.e delete then create new).
Petr Solin wrote:or delete target file, create new and write to it (link is deleted - it's what you suggest).
This is probably what I would expect if source and target files are linked to each other. However I also might expect to get an independent copy in the source and the original file (with other, external hardlinks still pointing to that copy's content). This realy depends on the purpose of the copy and how I intend to use the source or destination file after that.
Petr Solin wrote:I checked how this operation is solved in Explorer and Total Commander (TC).
It's ok to check, what others have done. However, hardlinks are fairly new to the Windows world and things are not established yet. Therefore better look where more experience flowed into the design and think through it yourself.
Petr Solin wrote:I was surprised that Windows XP does not handle directory listings with hard links properly - when I change the file, the linked file seems to be unchanged until I open it in viewer (or any other operation).
I am not at all. Windows can easly test whether a hardlink exists on a file, but there is no way for Windows to find out which other directory entry points to that same file data other than by scanning the directory tree and querying each file's ID-Nr (or whatever the analogon to unix's i-node number is called in NTFS). Windows (or explorer) could do a check on enumerating a directory's content, but that was not very effective to do.