I have the following scenario:
In my application, the user must have a specific dmg file mounted (at all times). This dmg contains some data the application needs to process and be always available.
I am looking at cases when "something goes bad". One of these cases is that the dmg file, while mounted, has been moved to another location (another folder etc).
To check this, I am using the hdiutil info -plist
command which produces a property list with all information for mounted dmg files.
The important keys of this property list for my case are the image-path
key and the image-alias
key;
The first is the actual location of the dmg (or the path from it was mounted originally) and the second is where the dmg actually is at the point when hdiutil is executed (has been moved).
image-path
is a string value - image-alias
is data object.
A typical plist looks like this:
<key>image-alias</key>
<data>
AAAAAAF0AAIAAAxNYWNpbnRvc2ggSEQAAAAAAAAAAAAAAAAAAADP
KL64SCsAAAAJ1UgMRVNNYXN0ZXIuZG1nAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABeS
ls/YacBkZXZpZGRza/////8AAAkgAAAAAAAAAAAAAAAAAAAACURv
d25sb2FkcwAAEAAIAADPKKKYAAAAEQcwB0AGUAcgAuAGQAbQBnAA
8AGgAMAE0AYQBjAGkAbgB0AG8AcwBoACAASABEABIAIVVzZXJzL3
BtYXIvRG93bmxvYWRzL0VTTWFzdGVy
</data>
<key>image-encrypted</key>
<false/>
<key>image-path</key>
<string>/Users/user/Downloads/Master.dmg</string>
(when opened in xcode the image alias data look like:
<00000000 01740002 6163696e 20484400 00000000 00000000 00000000 0000cf28 beb8482b 00000009 00000000 00000000 00000000 00000000 ... >
On the other hand, when running (terminal) the hdiutil info without the -plist (outputs on screen) it returns:
$ hdiutil info
framework : 371.1
driver : 10.9v371.1
================================================
image-path : /Users/user/Desktop/Master.dmg
image-alias : /Users/user/Desktop/Master.dmg
shadow-path : <none>
...
(this is what the command should return normally. On the "something went bad" case I'm looking at, image-path and image-alias should be different paths)
I have tried already to
NSData *aliasData = [NSData dataWithData:[images valueForKey:@"image-alias"]];
NSString *alias = [[NSString alloc] initWithData:aliasData encoding:NSSymbolStringEncoding];
with SymbolString, UTF, ASCII but it always return null.
So here comes the question:
Does anyone know what kind of Data is the image-alias object so that I can convert in string and use it accordingly?
Thanks in advance!