Is there a unix tool to which I can pass a file and have it tell me where the icon for the file is coming from?
What I am looking for is something like this:
$WhoProvidedIcon /Path/To/file.myex
UTI: com.myapplicati开发者_JS百科on.document
PLIST: /path/to/myapplication.app/Contents/Info.plist
ICON: /path/to/myapplication.app/Contents/Resources/BaseDoc.icns
Icons for most applications on Mac OSX are stored within the app bundle themselves. If you right click on the .app and then select Show Package Contents
then go to Contents -> Resources
you should see the icon in there.
There are at least three different place from which the OS will provide the icon.
In one situation, NSWorkspace can be used to help identify the location:
NSString* uti = [ws typeOfFile:@"/Users/egorr/Desktop/file.vwx" error:&error]; NSLog( @"UTI: %@", uti ); NSLog( @"UTI localized description: %@", [ws localizedDescriptionForType:uti] ); NSLog( @"UTI error description: %@",[error localizedDescription] ); NSURL* utiDeclarationURL = (NSURL*)UTTypeCopyDeclaringBundleURL( (CFStringRef)uti ); NSLog( @"UTI declaration URL: %@", utiDeclarationURL ); NSDictionary* utiDeclaration = (NSDictionary*)UTTypeCopyDeclaration( (CFStringRef)uti ); NSLog( @"UTI declaration: %@", utiDeclaration );
This won't quite get the path to the icon, but it will get one the application from which the declaration came for the UTI.
An icon might also be supplied from a Quick Look plugin and output from qlmanage can be used to determine if this is the case.
A user can, in Finder's Get Info window, set the application they prefer for all files of a given "type". One can set text file types to always open in TextMate, for example. TextMate the app provides custom file icons for all the file types it can save in. After making this change in Finder's get info windows, all files of that type will have an icon that has been provided by TextMate and registered with a UTI. To determine whether this is the case, one would need to look at the launch services database - lsregister -dump
I don't know of any specific tools that provide this information. However, it sounds like you have overlapping extensions. If Finder.app is showing an icon for a file then you should be able to just look in the info window for the file and see what application is listed to open the document by default. Then look at the .plist file for that application to see if it is using your extension. The info window should also say what kind of document it is which could be useful if the application that is supplying the icon has been deleted, or otherwise not listed as the default application.
精彩评论