Mac-Finder-DSStore
view release on metacpan or search on metacpan
DSStoreFormat.pod view on Meta::CPAN
=head1 DS_Store Format
Some notes on the format of the Macintosh Finder's F<.DS_Store> files.
=head1 OVERVIEW
The Mac OS X Finder stores information about how it displays directories
and files in files named F<.DS_Store> in each directory which it has touched.
(This seems to be a departure from the pre-OSX method of storing all the
information in one file at the root of each filesystem).
The format is not documented by Apple.
The information in this file is based on the reverse-engineering notes
by Mark Mentovai published on the Mozilla wiki,
and further investigation by me (Wim Lewis).
=head1 FILE FORMAT
The F<.DS_Store> file holds a series of records giving attributes of
the files in the directory or of the directory itself (referred to as
F<.>). These records are stored in a B-tree, and the pages of the
B-tree are stored in the file by a "buddy allocator" along with a
small amount of metadata. The allocator also provides a level of
indirection, from small integers to file offsets, presumably allowing
blocks to be relocated as they grow and shrink.
The file is generally big-endian. Unless otherwise noted, an "integer"
is a four-byte (32-bit) big-endian number, probably unsigned (but I'm
not always sure about that).
=head2 Records
A record has the following format:
=over
=item *
Filename length, in characters, as an integer. (4 bytes)
=item *
Filename, in big-endian UTF-16. Presumably with the same Unicode
composition rules as the HFS+ filesystem. (2 * length bytes)
=item *
Structure id or type, a FourCharCode indicating what property of the
file this entry describes. (4 bytes)
=item *
Data type (4 bytes), indicating what kind of data field follows:
=over
=item C<'long'>
An integer (4 bytes)
=item C<'shor'>
A short integer? Still stored as four bytes, but the first two are
always zero.
=item C<'bool'>
A boolean value, stored as one byte.
=item C<'blob'>
An arbitrary block of bytes, stored as an integer followed by that
many bytes of data.
=item C<'type'>
Four bytes, containing a FourCharCode.
=item C<'ustr'>
A Unicode text string, stored as an integer character count followed
by 2*count bytes of data in UTF-16.
=item C<'comp'>
( run in 3.169 seconds using v1.01-cache-2.11-cpan-71847e10f99 )