No navigation frame on the left?  Click here.

NTFS hard links

 

An even less common application for NTFS streams is the creation of hard links (Posix-style file links). These get done by writing, to a special stream, the full path of the new link to create. The sample lnw.cpp has all the gory details.

I am horrified by a bug in the previous version of lnw.cpp; the calculation of wsi.Size.QuadPart was just plain wrong (actually, whether it was correct or not depended on compiling for UNICODE or ANSI). This has been fixed, and I am grateful to Richard Borchu for pointing this out.  How embarrassing!

Today (10 Jul 2000), Armin Gerritsen <armin@examedia.nl> was kind enough to point out that CreateHardlink(), new with NT 5.0, returns an error 183 (ERROR_ALREADY_EXISTS) if a file with the name of the link-to-be is already present, while my NT 4.0-compatible implementation with BackupWrite() silently overwrote the existing file.  I adapted my code to behave like CreateHardlink() in this respect.

lnw.cpp, 5 KB, updated 10 Jul 2000