""" Mac OS X .DS_Store parser. Documents: - http://search.cpan.org/~wiml/Mac-Finder-DSStore-0.95/DSStoreFormat.pod Author: Robert Xiao Created: 2010-09-01 """ from hachoir_parser import HachoirParser from hachoir_core.field import (RootSeekableFieldSet, FieldSet, NullBytes, RawBytes, PaddingBytes, Bytes, SubFile, String, PascalString8, Bits, UInt8, UInt16, UInt32, Link, ParserError) from hachoir_core.endian import BIG_ENDIAN from hachoir_core.text_handler import displayHandler, hexadecimal from hachoir_core.tools import paddingSize class BlockAddress(FieldSet): static_size = 32 def createFields(self): yield displayHandler(Bits(self, "offset", 27, description="Offset into file divided by 32"), lambda x: hex(x*32).strip('L')) yield displayHandler(Bits(self, "size", 5, description="Power-of-2 size of the block"), lambda x: hex(1< 0: self.seekByte(offs.value+4) yield RawBytes(self, "free[]", size)