cocoamacosfile-manipulationmacfuse

How to associate a 4-char OSType / NSFileHFSTypeCode with a particular UTI


I am writing a MacFuse plugin, and would like finder to use the appropriate icons & launch the appropriate app when a file is opened.

It is not possible for me to add an extension to the file, so my only other option in Snow Leopard is the NSFileHFSTypeCode. I have reviewed all of the codes registered on my machine using http://www.rubicode.com/Software/RCDefaultApp/ and I can see that some of the codes are associated with UTIs. For example 'TEXT' is associated with the uniform type identifier (UTI) com.apple.traditional-mac-plain-text.

I would like to be able to associate some of these 4-char codes with other UTIs. For example PHPf to public.php-script. I imagine that there's some kind of framework or command line utility that would allow me to do this, but I have not been able to find it.


Solution

  • You need to declare the UTI in your bundle's Info.plist. If it's your own UTI, export it; if it's someone else's, import it.

    See the UTI docs for more information.