Re: Understand whether an application can open a specific file
Re: Understand whether an application can open a specific file
- Subject: Re: Understand whether an application can open a specific file
- From: Giovanni Donelli <email@hidden>
- Date: Sun, 2 Oct 2005 19:21:02 +0200
Thank you very much it does work!
Is there a specific manual for the launch services, something more
than a reference manual?
thanks
Giovanni
On 2 Oct 2005, at 3:46 PM, glenn andreas wrote:
On Oct 2, 2005, at 8:35 AM, Giovanni Donelli wrote:
Dear Folks,
is there a clever way to figure out whether an application X
can open a file Y or not?
I notice that if you drag, say a PDF file, over the icon of iCal
in the finder, iCal doesn't highlight notifying the user that the
application can't open that file.
is there a function such as: ApplicationCanOpenFileAtPath() ?
You'll need to drop down two Carbon, but LSCanURLAcceptURL in
LaunchServices.h will do this, but it's pretty trivial:
NSURL *appUrl = [[[NSURL alloc] initFileURLWithPath:appPath]
autorelease];
NSURL *docUrl = [[[NSURL alloc] initFileURLWithPath:docPath]
autorelease];
Boolean acceptsItem;
if (LSCanURLAcceptURL((CFURLRef)docUrl, (CFURLRef)appUrl,
kLSRolesAll, kLSAcceptDefault, &acceptsItem) == noErr) {
return acceptsItem;
}
return NO;
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden