9.3. Carbon File Manager

The original Mac operating system sought to make working with files as user friendly as possible. That meant favoring visual representations of file system data, such as folder and file icons, over the more traditional command-line access method. In fact, the operating system provided no command-line interface for selecting files of any kind; instead the user selected files and directories using open and save panels.

This philosophy extended into the Mac OS API as well. The Macintosh File Manager API was not built around a command-line interpreter. Instead the File Manager would identify files based on volume, directory, and file identifiers. Volumes were assigned a numeric value when they were discovered by the operating system. On HFS and HFS+ each file system directory had a unique number assigned to it. You could easily find any directory on a volume, no matter where it was, simply by referring to that number.

Over the years, the API evolved to make file references a little easier to work with. The Carbon API currently uses two kinds of structures to identify files: FSSpec and FSRef. While these structures are similar to each other in many ways, there are a few differences to keep in mind. Also, because the Carbon File Manager does not depend on file paths, it can track files on your local HFS disks even if they move. This feature is provided through aliases.

9.3.1. FSSpec and FSRef

System 7 introduced a single data type for referring to individual ...

Get Beginning Mac OS® X Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.