Version 9 of file link

Updated 2002-06-12 16:11:11

Purpose: to discuss the possibility of adding a new 'file link' command to Tcl. (see http://groups.google.com/groups?hl=en&lr=&ie=UTF8&oe=UTF8&th=887b11ac0fab6e29&rnum=4 )

Syntax:

file link ?-type linktype? source ?target?

(where linktype is either 'symbolic' or 'hard')


On Unix, this is easy with the OS calls'symlink' and 'link'. In fact a small patch is available on sourceforge http://sourceforge.net/tracker/index.php?func=detail&aid=562970&group_id=10894&atid=310894 to provide most of this on both Unix, and Windows! Also see TIP#99

On MacOS, links are also supported (often called 'aliases'), but we need a patch like the one above to allow links to be created (i.e. the TclpObjLink function in tclMacFile.c needs completing).

Windows 95/98/ME etc don't support links very much at all, but Windows NT/2000/XP using the NTFS filesystem (version 5, I think), do! See http://www.hlm.inc.ru/ for creating file-links, and http://www.rekenwonder.com/linkmagic.htm , http://windows.oreilly.com/news/win2kcommands_0401.html#linkd , http://www.codeproject.com/w2k/junctionpoints.asp , http://www.sysinternals.com/ntw2k/source/misc.shtml#junction for directory-links (the last two contain source code to create and query such links).

DKF - You could handle the 95/98 case by simply reporting that the OS/FS doesn't support links (IIRC, supposedly not all Unix FSes support links either, though I've never encountered one which had problems that wasn't a mount of something derived from CP/M,DOS,etc...) If only shortcuts weren't the work of the devil incarnate after more than a few beers!

Vince - Indeed, in Tcl 8.3 'file readlink' of course just returns 'invalid argument' under all versions of Windows. I've now uploaded a version of the patch to the sourceforge link above which contains an implementation for unix and windows.