Westwind Computing
 Sales Information
 Customer Feedback
Westwind Computing
[New to Westwind?]  [Customers]  [News & Information] 


Mac OS X: File Path Notations

By Gordon Davisson

Copyright (c) 2001, Westwind Computing inc.

Mac OS X is a descendant of both unix and previous Mac OS traditions, and has inherited different - and sometimes conflicting - ways of looking at things from both sides. One of these is the way the locations of files are described, generally referred to as file paths (i.e. the path to take to get to the file).

The biggest difference is in how the two traditions think about volumes (i.e. disks, partitions, server volumes, etc). In the Mac OS tradition, each volume is thought of as an independent entity; it shows up on the desktop as a separate icon, which contains everything on that volume. The only exception to this is files on the desktop; each volume can have its own desktop, and what you see on your screen is actually all of the volumes' desktops merged together.

The unix tradition, on the other hand, does not think of volumes (also known as "filesystems" in unix-speak) as independent entities in this way. Whichever volume the computer booted from is the main (or "root") filesystem, and all other mounted volumes show up like folders ("directories" in unix-speak) somewhere inside the root filesystem (or even inside each other). Usually, they're mounted in a standard location (unix traditionally uses a directory named "mnt" for this; in Mac OS X it's named "Volumes" instead), but not always.

Because Mac OS X needs to support programs from both unix and Mac OS backgrounds, it actually winds up looking at volumes both ways at various times, and what the volumes look like depends on how you look at them. The Finder (mostly) gives the traditional Mac OS-type view, while anything run from the command line will almost certainly give the unix-type view.

The clearest way to describe the differences is by looking at the paths you take to get to a file. For example, in traditional Mac OS, to get to a file in the Documents folder of your boot volume, you'd first open "Mac HD" (or whatever the volume happens to be named), then open "Documents", then "myfile" (or whatever the file is named). In the traditional Mac OS notation, this path would be written "Mac HD:Documents:myfile".

In unix, the step of going to the boot volume is not needed; it's the root filesystem, so starting there is semi-implicit(*). Also, unix uses slash instead of colon to separate steps in the path, so in unix notation the path to the same file would be "/Documents/myfile".

(* I say that starting at the root filesystem is semi-implicit because it's actually specified by the "/" right at the beginning of the path. If that'd been left off, the path "Documents/myfile" would mean starting from wherever you happen to be right now, go into a directory named "Documents" and use the file "myfile". In addition to the root filesystem, there are several other special places that a path can start: "~" means start at your home directory, so "~/Documents/myfile" would mean go to your home directory, then into your "Documents" directory, to a file named "myfile". There's also a variant of this to get to other users' home directories: "~george/Documents/hisfile" would mean go to george's home directory, then into his "Documents" directory, to a file named "hisfile".)

The Mac OS X Finder actually uses a hybrid notation, combining the Mac OS view of volumes as independent entities with unix's use of slash as the path separator.

Here are some examples of the paths to different files, in the two different views:
In English OS X Finder notation Unix notation
A file named "myfile" in a folder named "Documents" in the boot volume. /Mac HD/Documents/myfile /Documents/myfile
A file named "myfile" in a folder named "Documents" in another volume named "Spare". /Spare/Documents/myfile /Volumes/Spare/Documents/myfile
A file named "myfile" in a folder named "Documents" in a server volume named "Shared Files". /Shared Files/Documents/myfile /Volumes/Shared Files/Documents/myfile
A program named "BreezeEdit" in a folder named "Applications" in the computer's "Network" folder. /Network/Applications/BreezeEdit /Network/Applications/BreezeEdit

The other difference, between using colons and slashes as path separators, can also be a bit confusing. In the Mac OS tradition, colons are path separators, and cannot appear in the names of files or folders; slashes on the other hand are perfectly fine and are commonly used in filenames (e.g. "Meeting Notes 12/5/2000"). In unix, the situation is reversed: colons are fine in filenames, but slashes are forbidden. Mac OS X handles this by changing how filenames appear, depending on what the forbidden character is in a given context. For example, a file named "Meeting Notes 12/5/2000" by a Classic application will appear as "Meeting Notes 12:5:2000" under the command line. The Mac OS X Finder takes a middle road: it displays the names with slashes, but also uses slashes as path separators. The only place I've found that this actually causes a problem is that it means you cannot use the Finder's "Go To Folder" menu command to go to a folder with a slash (or colon if you prefer) in its name.

Also, in an attempt to avoid the confusion in the first place, Mac OS X sometimes tries to prevent you from using either colons or slashes in filenames; in some places it'll just refuse to let you enter them; in others it turns them all into dashes.

Home | Specials | Products | Education | About Us | Services | Training | Support | Reference | Events | How-to
   Copyright © 2000-2004 Westwind Computing