Re: mdbackup binary plist files
Re: mdbackup binary plist files
- Subject: Re: mdbackup binary plist files
- From: "Michael Ash" <email@hidden>
- Date: Thu, 17 Jul 2008 00:52:17 -0400
On Wed, Jul 16, 2008 at 11:15 PM, Ryan Chapman <email@hidden> wrote:
> Hopefully there is someone here who knows something about binary plist
> files. When an iPhone's firmware is upgraded in iTunes, a framework called
> MobileSync creates a backup of the iPhone's data files. The backup is
> stored in .mdbackup files, in ~/Library/Application
> Support/MobileSync/<targetId>/
> I've found that the .mdbackup files are Apple binary plists (the magic is
> bplist00, followed by 0xD4), however any attempts to read the files give the
> error "Conversion of data failed. The file is not UTF-8, or in the encoding
> specified in XML header if XML." I've tried the Property List Editor and
> the code below:
>
> #import <Foundation/Foundation.h>
> #import <stdio.h>
>
> int main(int argc, char **argv)
> {
> NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>
> NSString *path = @"./file42.mdbackup";
> NSData *plistData;
> NSString *error;
> NSPropertyListFormat format;
> id plist;
> plistData = [NSData dataWithContentsOfFile:path];
>
> plist = [NSPropertyListSerialization propertyListFromData:plistData
> mutabilityOption:NSPropertyListImmutable
> format:&format
> errorDescription:&error];
> if(!plist)
> {
> NSLog(error);
> [error release];
> }
> NSLog(@"%s", plist);
> [pool release];
> return 0;
> }
>
>
> Is there are way to use the Cocoa classes to read this type of binary plist,
> or am I stuck with straight C? If C is the only way, does anyone have a
> file structure (format) reference for binary plists?
NSPropertyListSerialization can read binary plists with no trouble, so
the fact that it doesn't work indicates that either your code is
broken or the file isn't really a binary plist, despite looking like
it is. Your code looks just fine, but I would recommend stepping
through it in the debugger (if you haven't already) to make sure
everything looks the way it should. In particular, make sure that it's
really reading the file you think it is, and that the data you get is
correct.
The format is available, although cryptic. A description can be found here:
http://www.cocoadev.com/index.pl?CrossPlatformPropertyListOrArchive
At the bottom of that page you'll find links to a working
implementation which, incidentally, I helped write. It's possible that
this code will read your file, and if it doesn't then it may
illuminate what's wrong with it.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden