OSType
OSType (also known as ResType) is the name of a four-byte sequence commonly used as an identifier in the classic Mac OS. While the bytes can have any value, they usually display figures characterized in software programs such as those used in ASCII or Mac OS Roman character sets.
OSType values are used to identify file data format types and the applications that created them. The separation of file types and creators allowed the coexistence of documents of the same format belonging to different applications; it is possible to reassign the ownership of any of these documents to any supporting application without changing its name or otherwise affecting its contents.
Macintosh file systems have a separate area for metadata distinct from either the data or resource fork. The catalogue entry for each file stores just the creation and modification timestamp, the file type code (one OSType) and creator code (another OSType), fork length, and the file name.
The resource fork of a file in a Macintosh file system stores an OSType identifier with each resource.
OSTypes are also used to identify the type of data in places other than files: for instance, on the Clipboard, or in AppleEvents. They tend to have common meanings across these uses: for instance, 'TEXT'
identifies a block of text (encoding unspecified, but usually ASCII or Mac Roman), while 'PICT'
indicates a QuickDraw picture.
Four byte identifiers are useful because they can be made up of four human-readable characters with mnemonic qualities, while still fitting in the four byte memory space typically allocated for integers in 32-bit systems. From a memory management standpoint, they're easier to handle than, for example, character strings of variable length. Compared to arbitrary 32-bit integer values, they are unambiguous since the byte-order is clearly defined. In programming, an OSType made of human-readable characters can be conveniently specified as a C multi-character literal, which allows you to specify an integer literal, whose bytes are made up of human-readable characters.
Since OS X 10.3, OSType signatures are one of several sources that may be examined to determine a Uniform Type Identifier and are no longer used as the primary data type signature.
Other uses for OSTypes include:
- as Gestalt selector codes
- as record field IDs and event type and class IDs in AppleEvents
- for identifying components in the Component Manager
- as “atom” IDs in the QuickTime movie and image file formats
- as a localization-independent way of identifying standard folders in the Folder Manager
- in QuickDraw GX, they were used as gxTag types and also as types of collection items in the Collection Manager.
- as error codes in certain libraries, such as QuickTime
FourCC is a system of data format identification used in some platform-independent multimedia containers, such as AIFF and RIFF. It inherits many codes from the OSType. A similar system is also used in TrueType font format.
See also
- Magic number
- Interchange File Format
- Uniform Type Identifier macOS's replacement for OSType based identifiers.
- FourCC, the corresponding concept on Microsoft Windows