Introduction
A Macintosh file can carry more than its contents: a resource fork, the Finder’s type and creator codes and flags, a comment, and on macOS extended attributes such as the quarantine flag set on downloads. Most other file systems have nowhere to keep them. AppleDouble and AppleSingle are Apple’s two ways of carrying them anyway, and Apple published both in a developer note, AppleSingle/AppleDouble Formats for Foreign Files. Version 2 is the one in use.
- AppleDouble splits a file in two: the contents stay in an ordinary
file, and everything else goes into a “header file” beside it. When macOS copies a file
to a FAT or exFAT drive or to a network share that cannot store these parts, it writes
that header file under the same name with
._in front:photo.jpggets._photo.jpg. The Finder’s Compress command does the same inside ZIP files, in a__MACOSXfolder, and macOS’starwrites them as members just before each file. - AppleSingle keeps the contents and the rest together in one file.
On a Mac, dot_clean merges ._ files back into the files they
belong to. Other systems show them as small extra files, usually 4,096 bytes, that can
be deleted if the Mac information is not needed. RFC 1740 uses both formats to send Mac
files by email, as application/applefile
and multipart/appledouble.
Structure
Both formats have the same layout: a 26-byte header, a table of entry descriptors, then the entries themselves. Numbers are big-endian throughout. Only the magic number tells them apart.
0Magic number00 05 16 07AppleDouble,00 05 16 00AppleSingle4 bytes4Version00 02 00 00for version 2,00 01 00 00for version 14 bytes8Filler zeros in version 2; macOS writes “Mac OS X” and spaces; the home file system in version 116 bytes24Number of entries2 bytes26Entry descriptors ID, offset and length of each entry12 bytes each…Entries wherever the descriptors sayvaries
| Offset | Size | Field | Value |
|---|---|---|---|
| 0 | 4 | Magic number | 00051607 AppleDouble, 00051600 AppleSingle |
| 4 | 4 | Version | 00020000, or 00010000 for version 1 |
| 8 | 16 | Filler | Zeros in version 2. macOS writes the text Mac OS X padded with spaces. In version 1, the home file system. |
| 24 | 2 | Number of entries | May be 0 |
| 26 | 12 × n | Entry descriptors | See below |
Entry descriptors
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 4 | Entry ID | What the entry holds, an unsigned number |
| 4 | 4 | Offset | From the start of the file to the entry |
| 8 | 4 | Length | The entry’s length in bytes; it may be 0 |
Entry IDs run from 1 to FFFFFFFF; ID 0 is invalid. Apple
reserves 1 to 7FFFFFFF for itself. The rest are left to applications, and
Apple does not arbitrate them.
Every entry is optional. Entries can come in any order and there may be holes between them, so a reader finds each one from its descriptor and never assumes they are contiguous. Apple recommends placing the resource fork last, as it is the entry most often extended.
Entries
The IDs Apple’s note defines are below. Their full layouts are on the Entries page.
| ID | Entry | What it holds |
|---|---|---|
| 1 | Data fork | The file’s contents (AppleSingle only) |
| 2 | Resource fork | The resource fork, in the Resource Manager’s layout |
| 3 | Real name | The file’s name on the Mac |
| 4 | Comment | The Finder comment |
| 5 | Black-and-white icon | 32 rows of 32 one-bit pixels |
| 6 | Colour icon | A colour icon, with no one fixed layout |
| 7 | File info | Version 1 only: the home file system’s file information |
| 8 | File dates | Created, modified, backed up and accessed, as signed seconds from 1 January 2000 UTC |
| 9 | Finder info | The Finder’s 32 bytes, and macOS’s extended attributes after them |
| 10 | Macintosh file info | The locked and protected bits |
| 11 | ProDOS file info | Access, file type and auxiliary type |
| 12 | MS-DOS file info | The MS-DOS attributes |
| 13 | Short name | The name an AFP server gave the file |
| 14 | AFP file info | The AFP attributes |
| 15 | Directory ID | The AFP ID of the file’s folder |
A ._ file from macOS has just two entries: Finder info (9), first, and the
resource fork (2), last, which is 286 bytes for a file that has no resources of its own.
AppleSingle
An AppleSingle file (magic number 00051600) holds a whole Macintosh file in
one stream: the data fork is entry 1, beside whatever other entries the file needs. An
AppleDouble file (00051607) has no data fork: entry 1 stays in the plain file
beside it, and the AppleDouble file carries only the other entries. The two share every
other byte of the format, so the header, descriptors and entries described here apply to
both. RFC 1740 says which to use when sending
a Mac file by email.
Files are paired and named by each file system’s
naming rules, which also give Apple’s
rules for writing and reading them. On ProDOS and GS/OS the files carry
file type
E0 with auxiliary type 0001 (AppleSingle), 0002
(AppleDouble header) or 0003 (AppleDouble data).
What a ._ file holds
Finder info (entry 9) is 32 bytes: the
file type and creator, the Finder flags and colour label, the icon’s position, an extended
part with more flags, and the folder the file returns to. macOS makes this entry longer and
keeps the file’s extended
attributes in it, after two bytes of padding, behind an ATTR header.
Common ones are com.apple.quarantine and Spotlight’s
com.apple.metadata: attributes, such as the address a file was downloaded
from, which are binary property lists.
The resource fork (entry 2) keeps its Resource Manager layout: a 16-byte header, 240 reserved bytes, the resources’ data and a map of their types, IDs, names and attributes.
The other entries hold names, comments, icons, dates and the attribute bits of the Macintosh, ProDOS, MS-DOS and AFP file systems.
Not described
Unknown
- Reference and viewer: the layout of the VAX VMS file-information entry, which Apple’s specification names but nobody has documented. Shown as labelled bytes.
Links
Software
- Finder – writes
._files on drives and shares, and in the__MACOSXfolder of ZIP files it makes (macOS) dot_clean– merges._files back into the files beside them (macOS)- Netatalk – AFP file server that stores Mac metadata as AppleDouble (Linux, BSD)
Reference
- RFC 1740 – MIME encapsulation of Macintosh files, which describes both formats
- vfs_xattr.c – the macOS kernel’s code that reads and writes
._files with their extended attributes