OSType

From Wikipedia, the free encyclopedia

OSType (also known as FourCC or ResType) is the name of a four-byte sequence commonly used as an identifier in Mac OS. While the bytes can have any value, they are usually characters from the 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 easy to reassign the ownership of any of these documents to any supporting application without changing its name or otherwise affecting its contents.

OSTypes are also used to identify the type of data in places other then files: for instance, on the Clipboard, in resources, 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.

Since Mac 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 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.

[edit] Other platforms

Similar four character codes are used to identify data types in many other operating systems and applications. These codes are generally referred to as FourCCs rather than OSTypes.

In other languages