For some reason I cannot do this on files inside bundles and files residing on different volumes.
Am I the only one experiencing this problem, and if not how do I solve it?
The Finder seems not having difficulties showing spotlight properties for the same files that I'm experiencing problems with.
I want to obtain the kMDItemKind of files as well as some other properties.
CFStringRef path = CFSTR("/Applications/Chess.app/Contents/Info.plist"); // bad
// CFStringRef path = CFSTR("/Applications/Chess.app"); // good
MDItemRef item = MDItemCreate(kCFAllocatorDefault, (CFStringRef)path);
if(!item) {
NSLog(@"MDItemCreate returned NULL for path: %@", path);
return nil;
}
CFStringRef kind = MDItemCopyAttribute( item, kMDItemKind );
if(kind) {
NSLog(@"file: %@ kind: %@", path, (NSString*)kind);
CFRelease( kind );
} else {
NSLog(@"file: %@ has no kMDItemKind attribute", path);
}
CFRelease( item );
OUTPUT:
file: /Applications/Chess.app/Contents/Info.plist has no kMDItemKind attribute
Same problem if I use the commandline tool mdls, like this
prompt> mdls /Applications/Chess.app/Contents/Info.plist
kMDItemFSContentChangeDate = 2009-05-19 08:09:03 +0200
kMDItemFSCreationDate = 2009-05-19 08:09:03 +0200
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = 0
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = 0
kMDItemFSLabel = 0
kMDItemFSName = "Info.plist"
kMDItemFSNodeCount = 0
kMDItemFSOwnerGroupID = 0
kMDItemFSOwnerUserID = 0
kMDItemFSSize = 3294
kMDItemFSTypeCode = ""
As you can see very little data is returned and no kMDItemKind
How would you obtain the metadata of the Info.plist ?