NAME
Data::Plist::BinaryReader - Creates Data::Plists from binary files
SYNOPSIS
# Create new
my $read = Data::Plist::BinaryReader->new;
# Read from a string
my $plist = $read->open_string($binarystring);
# Read from a binary file
$plist = $read->open_fh($filename);
DESCRIPTION
Data::Plist::BinaryReader
takes data formatted as one of Apple's binary property lists, either from a string or a filehandle and returns it as a Data::Plist
.
METHODS
read_misc $type
Takes an integer $type
indicating which misc is being read. Returns an array containing the type of misc and its associated integer.
read_integer $size
Takes an integer $size
indicating number of bytes needed to encode the integer (2**$size
= number of bytes). Reads that number of bytes from the filehandle and unpacks it. Returns an array containing the string "integer" and the value of the integer read from the filehandle.
read_real $size
Takes an integer $size
indicating the number of bytes needed to encode the float (see "read_integer"). Reads that number of bytes from the filehandle and unpacks it. The number of bytes is limited to 4 and 8. Returns an array containing the string "array" and the float read from the filehandle.
read_date $size
Takes an integer $size
, checks to ensure that it's within the proper boundaries, and then passes it to "read_real" to be dealt with, since dates are just stored as floats. Returns an array containing the string "date" and the date read from the filehandle.
read_data $size
Takes an integer $size
, indicating the number of bytes of binary data stored and reads them from the filehandle. Checks if the bytes are actually another binary plist and unpacks it if so. Returns an array containing the string "data" and the binary data read from the filehandle.
read_string $size
Takes an integer $size
indicating the number of bytes used to encode the UTF-8 string stored and reads them from the filehandle. Marks them as Unicode and returns an array containing the string "string" and the string read from the filehandle.
read_ustring
Takes an integer $size
indicating the number of bytes used to encode the UTF-16 string stored and reads them from the filehandle. Returns an array containing the string "ustring" and the string read from the filehandle.
read_refs $count
Takes an integer $count
indicating the number of references in either a dict or an array. Returns the references pointing to the locations fo the contents of the dict or array.
read_array $size
Takes an integer $size
indicating the number of objects that are contained in the array. Returns an array containing the string "array" and the references pointing to the location of the contents of the array in the file.
read_dict $size
Takes an integer $size
indicating the number of key-value pairs contained in the dict. Returns an array containing the string "dict" and the references pointing to the location of the key-value pairs of the dict in the file.
read_uid $size
Takes an integer $size
indicating number of bytes needed to encode the uid (2**$size
= number of bytes) and then passes it to "read_integer" to be dealt with, since uids are stored identically to integers. Returns an array containing the string "uid" and the uid read from the filehandle.
binary_read $objNum
Takes an integer indicating the offset number of the current object $objNum
and checks to make sure it's valid. Reads the object's type and size and then matches the type to its read method. Passes the size to the correct method and returns what that method returns.
open_string $string
Takes a string of binary information in Apple's binary property list format $string
. Checks to ensure that it's of the correct format and then passes its superclass's "open_string". The error proofing is done because seeking in in-memory filehandles can cause perl 5.8.8 to explode with "Out of memory" or "panic: memory wrap".
open_fh $filehandle
Used for reading binary data from a filehandle $filehandle
rather than a string. Opens the filehandle and sanity checks the header, trailer and offset table. Returns a Data::Plist
containing the top object of the filehandle after it's been passed to "binary_read".