Important: The information in this document is obsolete and should not be used for new development.
File IDs
A file ID is a unique number that the File Manager assigns to a file at the time it is created. The File Manager uses file IDs to distinguish one file from another on the same volume. In fact, a file ID is simply the catalog node ID of a file. As a result, file IDs are functionally analogous to directory IDs (described in the next section), and both kinds of IDs are assigned from the same set of numbers.The File Manager can set up an internal record in the volume's catalog that specifies
the filename and parent directory ID of the file with a given file ID, allowing you to reference the file by that number. (For more information about the volume's catalog,
see "Catalog Files" on page 2-70.) This internal record in the volume catalog is a file ID reference (or file ID thread record).It is important to distinguish file IDs from file ID references. File IDs exist on all HFS volumes, but file ID references might or might not exist on a particular HFS volume. Even if file ID references do exist on a volume, they might not exist for all the files on that volume. In addition, you can track files by their file IDs only on systems capable of creating and resolving file ID references. See "File ID Reference Routines" on page 2-23 for a description of the File Manager functions that allow you to manipulate file IDs.
A file ID is analogous to a directory ID. A file ID is unique only within a volume and remains constant even when the file is moved or renamed. When a file is copied or restored from backup, however, the file ID changes. File IDs are unique over time--that is, once an ID has been assigned to a file, that number is not reused even after the file has been deleted.
- Note
- The file ID is a low-level tool and is unique only on one HFS volume. In most cases, your application should track files using the Alias Manager, described in the chapter "Alias Manager" in this book. The Alias Manager can track files across volumes. It creates a detailed record describing a file that you want to track, and, when you need to resolve the record later, it performs a sophisticated search. The Alias Manager uses file IDs internally.
The file ID is a permanent file reference, one that a user cannot change. After storing a file ID, your application can locate a specific file quickly and automatically, even if the user has moved or renamed it on the same volume.
File IDs are intended only as a tool for tracking files, not as a new element in file specification conventions. Neither high-level nor low-level File Manager functions accept file IDs as parameters.