AbsolutePath is Evil! (Usually)

Contributed to the public domain by Lars Jensen
Updated Oc 16, 2004

One of my first REALbasic creations was a platform-independent subsystem for parsing and manipulating paths, based on FolderItem.AbsolutePath, converting code I had previously written in C++. That turns out to have been pretty much a waste of keystrokes, because using absolute paths to specify files is a fundamentally unsound thing do on Macintosh. The problem is that Macintosh volume names don't have to be unique. Thomas Reed's excellent write-up on this topic details the ways this can bite you.

There are a few legitimate uses of AbsolutePath:

- Specifying files when calling an embedded AppleScript
- Using Declares with File Manager functions
- Displaying a filename to the user

Otherwise, you should:

- Pass a file or folder as a FolderItem instead of a path string
- Use FolderItem.Parent and .Child properties to traverse directories
- When you do need to store a path, use FolderItem.GetSaveInfo

For more info, see "FolderItem" within the REALbasic documentation.



©2003-2004 Lars Jensen, except where specified. Please email us with errors or topic ideas.