views:

68

answers:

0

Given an application path (or NSBundle to an application, etc), is there a way to easily/efficiently determine what content types that application can open?

My initial attempt was to read the application's Info.plist file and extract the content types listed under the kUTExportedTypeDeclarationsKey key. However, there are some flaws with this approach which I haven't been able to work around.

  1. Not all applications use this key. For example, BBEdit does not, but instead lists a whole bunch of recognized file extensions.
  2. UTIs are case-sensitive. Pages, for example, lists com.apple.iWork.Pages.pages as an exported content type, yet no Pages document actually has that type listed in its content type tree. Documents use com.apple.iwork.pages.pages, which is defined by the iWork quicklook generator (at /Library/QuickLook/iWork.qlgenerator).

In know that with some of the LaunchServices functions (LSCopyApplicationURLsForURL(), LSCopyApplicationForMIMEType(), etc), I can get the applications that can open a file (or a file type), but I'd like to do the inverse. (Perhaps I'll have to resort to parsing the output of lsregister -dump?)

Perhaps a simpler way to phrase the question would be: Given an application, what's the easiest way to find all files that it can open?

Any suggestions?