Updated 2013-08-13 01:20:33 by RLE

* Anyone knows how to create OSX file and desktop shortcuts using Tcl? I believe they are called "alias"

Lars H: You might get by with creating a symbolic link, but proper aliases may be better as they do provide some additional functionality (for example, the target can often be found even if the folder it's in has been moved). Examining Alpha's Mac Menu [1] recovers the following TclAE command for telling the Finder to create the alias:
  tclAE::send 'MACS' core crel kocl type(alia)\
    insh [tclAE::build::foldername $where]\
    "to  " [tclAE::build::filename $sourceFile]

Oh, and BTW "shortcut" is entirely the wrong name for this. In Mac HIG terminology, a "shortcut" [2] is mostly the same thing as a key binding.

MG Although "alias" may be the right name, I daresay far more people trying to find out how to do this will search for "shortcut", unless they happen to be avid Mac users. As someone who primarily uses Windows (but tries to write things to work cross-platform), I'd never be able to find the page if it were called 'MacOS X Aliases'. (</rant> ;))

DLR Agree! As the initial purpose of the page was exactly that, the confusion over what the Mac equivalent was for shortcuts :)

And now a question, for anyone who knows: does file link not work (or not work sufficiently) on MacOS? Or is it just that the above method provides more functionality?

Lars H: Whether file link works depends (as in all Unices, I think) on the target filesystem more than on the OS. In HFS+ file systems (which has been the default from Mac OS 8.0 and on) there can be symbolic links but no hard links. UFS file systems support hard and symbolic links. ISO9660 probably doesn't support links at all (but there are plenty of extensions of it around, so you never know).

An alias (as created by the above command) is a higher level construction -- really a file that is understood by e.g. the Finder and standard Open File dialogs as a reference to some other file, and it is thus not as dependent on the capabilities of the file system. Aliases keep track of more information about their targets than just the POSIX path and generally manage to keep track of files even if they have been moved; they may even reliably reference objects on remote servers that you're not logged in to (in which case an Open will typically trigger a login).

MG Ahh, I see. Thanks for the very clear explaination, Lars :)

BH: I believe the RockRidge extensions to ISO9660 allow the use of softlinks (among other things).