Jan, Your builtin link() is a godsend! If only I'd known years ago.... I could have saved a lot of heartache trying to kludge Win32::API::Prototype into working in my programs.
I did a lot of testing of link() over this last weekend, and got mixed results. Here's my test environment: \FolderA\LinkTest.txt Original file \FolderA\FolderB\LnkdFil1.txt First hardlink \FolderA\LnkdFil2.txt Second hardlink I create a straight copy of an original text file in FolderA, naming it "LinkTest.txt". I create a hardlink to "LinkTest.txt" in FolderB, naming it "LnkdFil1.txt". I test that it is an actual hardlink by opening and editing both files; changes to either file show up in the other when opened. So far, so good. But then I create another hardlink to "LinkTest.txt" in FolderA (same folder as "LinkTest.txt" this time), naming it "LnkdFil2.txt". Now I should have a total of three filesystem hardlinks pointing to the single original file on disk, right? I unlink the original "LinkTest.txt", and that should leave me with two remaining links to the same file on disk (since NTFS uses link counting, in much the same way as Perl employs reference counting). But testing demonstrates that I now have two separate files on disk -- each with a single link to it -- rather than two links to the same file. Do I have a bad understanding of the concepts, of how hardlinks are supposed to work? Am I doing something wrong, or in the wrong order? Or is there some deficiency in the implementation of Windows hardlinks through link()? One final question: since symlinks were enabled in NTFS.sys v6.0 (Windows Vista) and above, is there any possibility that the builtin symlink() function can be made to silently Do the Right Thing on recent versions of Windows? Windows requires explicit declaration if the symlink is to a directory, but I think that it could be implemented in Perl in such a way that Perl simply handles the symlink() call correctly -- no matter what arguments it is handed. Here is the /? for the most recent MKLINK command: MKLINK [[/D] | [/H] | [/J]] Link Target /D Creates a directory symbolic link. Default is a file symbolic link. /H Creates a hard link instead of a symbolic link. /J Creates a Directory Junction. Link specifies the new symbolic link name. Target specifies the path (relative or absolute) that the new link refers to. At this point, we should have all of the linking functionality in Windows that is available in *nix. Thank you, -Brian Quoting "Jan Dubois" <j...@activestate.com>: > On Thu, 17 Feb 2011, Brian H. Oak wrote: >> For years now I've been using Win32::API::Prototype to access >> kernel32.dll and set up CreateHardLink() for use in a program. But >> something in the upgrade from 32-bit 5.10 to 64-bit 5.12 is >> incompatible with Win32::API::Prototype. Now I'm looking for an >> alternative method for creating hard links that works with 64-bit >> 5.12. Does anyone know of a compatible module that provides this >> functionality? > > Have you tried the link() builtin function? It should call the > CreateHardLink() function internally. I think I implemented it > back in the 5.004 or 5.005 days, with an compatibility hack > for Windows NT4, which doesn't have CreateHardLink(). > > Anyways, please let me know if it doesn't work; it is supposed > to do the right thing automatically. > > Cheers, > -Jan _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs