Mac file types

Background information

Microsoft Windows uses the filename extension (which is required) to determine a file's type. Apple's Mac OS X uses the filename extension (if present) and in addition uses the file type and creator codes (if present) stored in the catalog entry for the file. This allows Mac OS X to be compatible with the external world (i.e. Windows and Unix, which use filename extensions) and with Mac Classic (which exclusively used Mac file types).

Successfully exchanging files in a mixed platform environment requires performing a mapping between Mac file types and filename extensions. And since the catalog entries for file type and creator codes are supported only by Mac-specific file systems (such as HFS), they must be emulated on foreign file systems (such as FAT).

Mac OS X (and Mac Classic) also allows files to have a resource fork (a second stream of information in addition to the main data). In its most extreme form, a file may store all of its information in the resource fork and have zero data bytes (as is the case for certain types of Classic font files). Modern applications tend to rely less on the contents of the resource fork than Classic applications, but in general the resource fork cannot be ignored.

Again resource forks are directly supported only by Mac-specific file systems, and thus must be emulated on foreign file systems.

Emulation with dot-underscore file (AppleDouble)

When a Mac OS X user copies a file from a Mac-specific volume to a foreign volume, the system splits out any information that is not located in the data fork of the file and writes it to a hidden file on the destination volume. The name of this file is the same as the original file except that it has a dot-underscore prefix. For example, if the user copies an file named MyMug.jpg to a foreign volume, there will be a file named ._MyMug.jpg in addition to the MyMug.jpg file in the same location.

When a Mac OS X user copies a file from a foreign volume to a Mac-specific volume, the system looks for a matching "dot-underscore" file. If one exists, the system uses the information in the dot-underscore file to recreate the resource fork and file type attributes. If the hidden file does not exist, these attributes are not recreated.

Emulation using NTFS alternate data streams

Although this feature is not widely known, the NTFS file system (used by most modern Microsoft Windows systems) supports alternate data streams in a file. In a way this feature is a generalization of the Mac resource fork concept. Each individual stream can be opened for input or output, but otherwise the file (with all its associated streams) is managed as a single unit. The Windows user interface provides no interface to alternate data streams, and regular Windows applications never use alternate data streams.

Several AppleTalk file sharing protocol (AFP) implementations for Windows servers, including Microsoft's own implementation, emulate Mac file types and resource forks on the Windows NTFS file system using alternate data streams. Note that these AFP implementations do not support the FAT file system since it doesn't offer alternate data streams.

This mechanism has the benefit of storing the emulated information in one single file with the regular data. However the presence of this extra data is extremely hard to detect for a Windows user (i.e. only through specialized shareware utilities).

Furthermore, while the Windows file system correctly copies any alternate data streams with a file, the extra information is lost when the file is attached to an email message or when it is stored in an archive such as a ZIP.

Automatically adding filename extensions

On Windows a file must have a filename extension for it to be correctly recognized by the applications operating on it; so there is almost never a reason for not including the extension that is appropriate for the file's type.

Even on Mac OS X, while it is not a requirement, there seem to be several factors in favor of including filename extensions when working with automated processes:


Therefore Switch offers a function to automatically add an appropriate filename extension to arriving files, based on Mac file type information associated with the file. This feature is turned on by default (recommended), and it can be turned off in the preferences dialog.

Specifically, when Switch detects that a new file has arrived (and the "add filename extension" feature is enabled), Switch looks for Mac file type information in the following way:


If Switch finds meaningful Mac file type information, and if it can locate the corresponding filename extension in its built-in table, and if the file doesn't already have the appropriate filename extension, Switch will add the filename extension to the file's name. Otherwise the filename is left unchanged.

Copying files

When Switch copies or moves a file under its own control (for example, between two folders), it ensures that all available Mac file type information and resource fork data is copied along with the file. (On Mac OS X this means using the native file operations; on Windows this involves supporting the emulations discussed above).

This preserves Mac file type information (which may be superfluous if a filename extension is also present), but more importantly it also preserves any resource fork data - which allows, for example, to process Classic Mac fonts through Switch on a Windows system.

Note however that other processes and third-party applications may not carry along Mac file types and resource forks. On Windows this is almost never the case, and even on Mac some modern applications no longer support these Classic features.

Changing the file type

The file type tool allows setting a file's filename extension and/or Mac file and creator types to a specified value. This is handy if you know the correct type of a file (for example, because it was created by an application under your control) but you suspect that it may not have the appropriate filename extension or Mac file type information.

Filtering on file type

Several Switch tools offer the possibility to sort files based on file type; see Specifying file filters.