Developer --\> Technical Publications
PATH  Mac OS X Server Documentation > Mac OS X File System Conventions

[previous] [table of contents] [next]

Search Paths

The organization of Mac OS X's standard directories and their contents form the basis for a search strategy used by the Workspace Manager and all other well-behaved Mac OS X applications. When a user double-clicks a file, for example, the Workspace Manager must locate the appropriate application to start. If there are several versions of this application--say one in /Local/Applications and another in /Network/Applications--the Workspace Manager must enforce a policy that determines which version has precedence.

The Workspace Manager finds executable files by using a search path, an ordered set of directories. For example, the Workspace Manager searches for applications in these directories, in the order listed:

  1. ~/Applications (the Applications directory within the user's home directory)
  2. /Local/Applications
  3. /Network/Applications
  4. /System/Applications

Similarly, to determine which version of a given font to use, the Application framework searches this path:

  1. ~/Library/Fonts
  2. /Local/Library/Fonts
  3. /Network/Library/Fonts
  4. /System/Library/Fonts

The policy expressed by these search paths is that a user's private copy of an application or resource should take precedence over one that's shared by all users of a machine (that is, one placed in /Local), that a locally shared copy should take precedence over one that is shared over the network, and finally that a networked version should take precedence over one that is distributed as part of the system software. Thus, a company might make a word-processing template available to all employees by installing the template in /Network/Library/SomeWordProcessor/CompanyTemplate.xyz. However, someone in the company's Art Department, for example, can override this networked template by putting a customized version in /Local/Library/SomeWordProcessor/CompanyTemplate.xyz.

Where resources or applications do not collide with one another (two versions of the same application, for instance), this search routine simply provides a cumulative list of resources or applications. For example, the list of fonts displayed in the Font panel includes all those found in ~/Library/Fonts, /Local/Library/Fonts, /Network/Library/Fonts, and /System/Library/Fonts. Another example is evident in the Workspace Manager's Content inspector. The Workspace Manager searches all the standard Applications directories to discover which applications handle a specific file format.

All Mac OS X applications should adhere to this policy in searching for resources. For some resources, the work has already been done for you: The Font panel finds its fonts and the Color panel finds its color pickers using the standard search path. But to locate resources that are unique to your application (say loadable bundles that implement drawing tools), your application should use the NSSearchPathForDirectoriesInDomains function, which implements Mac OS X's ordered search routine.

[next]