« My First Credit | Home | Ski Resort in Dallas »

Individual Entry With Comments

September 19, 2007

Vista Gem #5

Filed under Computers, Programming, Software


Just learned about this one today.

Windows Vista supports both hard links and symbolic links. The command line option to do this is called "mklink." It doesn't appear that the GUI (explorer) supports creating symbolic/hard links. Once they are created, the GUI can modify and delete the symbolic/hard links.

A symbolic/hard link is similar to a Windows shortcut, but more powerful. A symbolic/hard link acts just like the file/directory it points to. If you are writing an application that will open a file, you don't a have to do anything special to read a symbolic/hard link...just read the file normally. A shortcut is just a text file with information about the file/directory it points to. In Windows, shortcuts work effectively as symbolic links. From the command line, they don't.

For example, you have a text file named "happy.txt" with a shortcut called "happy.txt - Shortcut.lnk" If you double-click on the shortcut, Windows will open happy.txt as you would expect. From the command line, type "more happy.txt - Shortcut.lnk" and you will see the contents of the shortcut and not the contents of original file happy.txt. If you tried the same thing with a hard/symbolic link, you would get the contents of happy.txt in each case.

Probably not that interesting to Windows users, but *very* interesting to people bringing software over from the UNIX world where symbolic/hard links are commonly used. Now that it is a standard part of the console on Windows, I would expect more people (especially software developers) to start using it.

This article has a couple of nice pictures that describes the difference between hard links and symbolic links. Basically, a hard link points directly at the data and a symbolic link points at the filename that points at the data. It's a subtle difference. This website does a nice job of comparing the two types of links. A symbolic link can exist when the data has been removed, a hard link can't. You can use a symbolic link on your hard drive to point to a file on your USB flash drive. If you remove the USB flash drive, the symbolic link will point to nothing until you return the USB flash drive. You can't make a hard link from your hard drive to a USB flash drive.

Windows has actually had hard link support since Windows 2000, but it was only available through an API call (CreateHardLink), had no command line option, and it only worked on NTFS. Back in 2000, most systems used FAT, so hard links were of little value.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


This page contains a single entry from the blog posted on September 19, 2007 10:34 PM.

The previous post in this blog was My First Credit.

The next post in this blog is Ski Resort in Dallas.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.34