OSType
From open-encyclopedia.com - the free encyclopedia.
OSType (also known as "ResType") is the name of a four-byte type commonly used as an identifier in Mac OS. The four bytes could in principle have any binary value, though they are usually ASCII or characters from the Mac Roman character set.
Macintosh platform
OSType values were used to identify file data format types, as well as 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 was easy to reassign the ownership of any of these documents to any supporting application, without changing its name or otherwise affecting its contents.
OSTypes were also used to identify the types of data in other places besides files: for instance, on the Clipboard or in resources, as well as in AppleEvents. They tended to have common meanings across these uses: for instance, 'TEXT' meant a block of text (encoding unspecified, but usually ASCII or Mac Roman), while 'PICT' meant 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 more easy 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.
Other uses for OSTypes were:
- 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 table IDs in the TrueType font format
- 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.
Other platforms
In 1985 Electronic Arts introduced the Interchange File Format (IFF) meta-format (family of file formats), originally devised for use on the Amiga. These files consisted of a sequence of "chunks" which could contain arbitrary data, each chunk prefixed by a four-byte ID.
This IFF was adopted by a number of developers including Apple for AIFF files and Microsoft for RIFF files (which were used as the basis for the AVI and WAV file format). Microsoft and Windows developers refer to their four-byte identifiers as Four Character Codes (FourCC).
Other file formats that make important use of the four-byte ID concept are the Standard MIDI File Format, the PNG image file format and the ICC profile format.