AppleSingle & AppleDouble

Summary: Technical explanation page on AppleSingle and AppleDouble formats, created by Apple to support its multifork files on fork-agnostic server and media.
 

Introduction

All file systems must store, manage and retrieve data and metadata. However, since the creators of the Macintosh file system chose to implement not only a data fork, but also a resource fork (see our page on Macintosh forks for more information), a solution was found to store both forks in a single file on Macintosh disks (HFS for Hierarchical File System and HFS+, better known as Mac OS Extended), while the metadata (signatures, etc.) is stored in the file tree (not in the file itself).
However, files never stay bound to the disks on which they were created. This was true in the past, when the BinHex and MacBinary standard were specified to allow storing Macintosh on the first data servers.
When Apple chose to support FAT media on the Macintosh computer, they also had to manage those forks on such fork-agnostic volumes. We had in the past the well known Apple PC-Exchange and Apple uses today the AppleDouble format on the FAT32 volumes. Ever seen one of those dot-underscore files, where you have a file named mainfile and another one named ._mainfile?

Magic Signatures

One of the problems of those former solutions (still heavily used, nevertheless) is that it is difficult to ascertain the very nature of the file from outside and even from inside.
Therefore, Apple chose to use so-called magic signatures. The magic signature of AppleSingle files is 0x00051600, while it is 0x00051607 for AppleDouble files. This signature is to be found in the first four bytes at the beginning of the single file in the case of the AppleSingle standard and at the beginning of the header file (file containing everything but the data fork) in the case of the AppleDouble standard.
Caution as always because of the big-endianess. The bytes are in the stated order in the file.

AppleSingle

The AppleSingle standard creates a single file (thence its name) in which the first bytes contain a data structure pointing to the different parts of the file (file name, file dates, finder information, data fork and resource fork).

AppleDouble

On the other hand, the AppleDouble standard foresees two files. One contains the data fork, it is called the main file. On a FAT volume, it is stored under the file name given by the user.
A second file, generally prefixed with '._' (under Unix, file names beginning with a dot are considered as hidden files), contains a data structure (very similar to the structure used in AppleSingle files) and the resource fork.
The header file can't be empty. The mainfile can be empty. The header file can exist for a folder.

Utilities

Both formats are managed by MacMail and by our new Mac2SFM.

 
Pierre Duhem (ex-Logiciels & Services Duhem)
3, rue Pierre Haret - F-75009 Paris (France) - Tel. (+33) [0]149 700 455
web: http://www.macdisk.com