Skip copy/move file(s) to their hard copies
Posted: 2010-04-01, 05:42 UTC
Today I tried to copy some file into another folder. TC said that access is denied, I tried as admin, but no result. I searched in Process Explorer - no open handles! Then I got an idea that perhaps another hard file copy might be protected (tooltip said that there are two copies). But then I got mind that I try to copy file over its hard copy!
I checked file indexes in tooltip (my NTLinks plugin provides such field) - they was the same!
So a simple suggestion - to skip file copy over its hard link, also if user tries to move file over its hard copy, TC may just delete source file - because these files really the same!
Of course, TC should do this check only if OS doesn't allow to open target file. And, if TC sees that files are on the same drive and have same file system ID, it may safely skip operation (for copy) or delete source file (for move).
BTW it is good that OS doesn't allow to open file twice - else TC will reset file contents while copying.
To compare indexes of files TC may use GetFileInformationByHandle function and compare nFileIndexHigh and nFileIndexLow fields of returned structure for both files. Function is available under Windows 2000 and later.

So a simple suggestion - to skip file copy over its hard link, also if user tries to move file over its hard copy, TC may just delete source file - because these files really the same!
Of course, TC should do this check only if OS doesn't allow to open target file. And, if TC sees that files are on the same drive and have same file system ID, it may safely skip operation (for copy) or delete source file (for move).
BTW it is good that OS doesn't allow to open file twice - else TC will reset file contents while copying.
To compare indexes of files TC may use GetFileInformationByHandle function and compare nFileIndexHigh and nFileIndexLow fields of returned structure for both files. Function is available under Windows 2000 and later.