On Wed, Jan 14, 2009 at 2:14 AM, Randall Meadows <cocoa-...@not-pc.com>wrote:
> I'm just making sure I'm not missing something... > > There's no system-defined way to go from a UTI to an old-style file type > code (which the UTI docs seem to refer to as a "tag") and back again, am I > correct? > extern CFStringRef UTTypeCopyPreferredTagWithClass( CFStringRef inUTI, CFStringRef inTagClass) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; extern CFStringRef UTTypeCreatePreferredIdentifierForTag( CFStringRef inTagClass, CFStringRef inTag, CFStringRef inConformingToUTI) /* can be NULL */ AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; extern CFArrayRef UTTypeCreateAllIdentifiersForTag( CFStringRef inTagClass, CFStringRef inTag, CFStringRef inConformingToUTI) /* can be NULL */ AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; > > For instance, my app can export files as TIFF, JPEG, or PNG. When the user > makes the selection, I convert the selection popup menu to the appropriate > UTI using the defined constants in UTCoreTypes.h (kUTTypeTIFF, et al). I'd > like to generalize the subsequent code to take that UTI ("public.tiff" for > example) and convert it to the appropriate type code ('TIFF'). The next > logical step would be producing a file name extension based on that as well > ("public.tiff" -> "tif"). > > *All* this information is contained in the table at < > http://developer.apple.com/documentation/Carbon/Conceptual/understanding_utis/utilist/chapter_4_section_1.html#//apple_ref/doc/uid/TP40001319-CH205-CHDIJFGJ>, > but I could discern no way to actually do these types of conversions in a > general manner. > > History: The reason I need to do this is, Photoshop is brain-dead when it > comes to opening image files that happen to have no extension in the > filename (and no file type code). Preview, QuickTime Player and > GraphicConverter (and sometimes Safari) have NO problem identifying and > opening the exact same files, sans extension, but PS simply says "Could not > complete your request because Photoshop does not recognize this type of > file." I am working around this by attaching type and creator codes to all > the image files I export. (Yes, my client could avoid all this by simply > including an extension to the image name, but old dogs, new tricks, and all > that...) > You always can teach new tricks to old dogs... it's significantly more difficult for human beings. -- Julien _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com