Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: file associations




On Jan 12, 2007, at 2:24 PM, Daniel Birns wrote:
I have a related concern. Our application is associated with documents that have a .dart suffix. The problem is that that suffix is already used by Apple: com.apple.disk-image-dart.

We can't really change it, because it's already in use on other platforms. And we like it.

Currently I'm overriding this default in a way that's working but is kind of ugly. I haven't encountered a .dart disk image before, and it doesn't seem to be in much use, so I think overriding this is fairly safe.

Here's how I'm doing it:

{ defaults read com.apple.LaunchServices 2>&1 | grep dartdevices.dartplayer > /dev/null
} || {
defaults write com.apple.LaunchServices LSHandlers -array-add '<dict><key>LSHandlerContentType</key><string>com.apple.disk-image- dart</string><key>LSHandlerRoleAll</ key><string>com.dartdevices.dartplayer</string></dict>'
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/ LaunchServices.framework/Support/lsregister -kill -r -domain local - domain system -domain user
}

Oh, please, don't do this. The preferences file could change in the future, causing this technique to stop working or, worse, to break other binding preferences. Also, rebuilding the whole LS cache can have other side effects, and it's very expensive.


Happily, there is API which will do exactly what you want. Here is function call to make:

OSStatus err = LSSetDefaultRoleHandlerForContentType(CFSTR ("com.apple.disk-image-dart"), kLSRolesAll, CFSTR ("com.dartdevices.dartplayer"));

That's it. No need to rebuild, or worry that you're doing it twice, or whatever. It takes effect immediately. The LS API is pretty well documented -- please look over the API to see what other functions you may have a need for. The reference can be found here:

http://developer.apple.com/documentation/Carbon/Reference/ LaunchServicesReference/index.html

Finally, I'd like to point out that some user, somewhere, may actually use dart disk images, so it would be best to ask the user before changing the .dart binding preference.

-Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >file associations (From: Daniel Birns <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.