Re: Is OSACopyScriptingDefinitionFromURL broken?
Re: Is OSACopyScriptingDefinitionFromURL broken?
- Subject: Re: Is OSACopyScriptingDefinitionFromURL broken?
- From: has <email@hidden>
- Date: Tue, 11 Nov 2014 20:50:13 +0000
Shane Stanley wrote:
> On 31 Oct 2014, at 6:27 am, has <email@hidden> wrote:
>
>> If someone else can confirm the same behavior on their machine, I'll
file a bug report on it.
>
> Confirmed. I have a vague recollection that it works for non-local
URLs, but I may be mis-remembering. Radar #15379481, closed as a dupe of
#14298245 (Open).
Thanks Shane. Finally submitted it (Radar #18944184) with a patch that
any code monkey should be able to apply in 5 minutes flat.
I've also submitted a separate bug report on
OSACopyScriptingDefinition() as it uses deprecated Carbon FSRefs and
therefore needs to be deprecated itself (Radar #18944369).
Regards,
has
-----------------------------------------------------
Radar #18944184
11-Nov-2014 08:23 PM
The OSACopyScriptingDefinitionFromURL() documentation (ASDebugging.h)
states "If used with a file: URL, this call is equivalent to
OSACopyScriptingDefinition."
However, using a file: URL returns an sdef containing Apple Event
Manager's XML-RPC/SOAP terminology. This is a known bug (see Radar
#15379481, #14298245) affecting OS X 10.10, 10.9, and probably earlier
releases.
This bug needs to be fixed as the only alternative API,
OSACopyScriptingDefinition(), requires an FSRef argument, which rules
out its use in AppStore-hosted products and is generally undesirable due
to the FSRef type and its associated functions being deprecated in 10.9.
The following code provides a quick and easy fix that can be applied
with little or no tweaking:
extern OSAError OSACopyScriptingDefinitionFromURL(CFURLRef url, SInt32
modeFlags, CFDataRef *sdef) {
OSAError err = noErr;
CFStringRef scheme = CFURLCopyScheme(url);
if (CFStringCompare(scheme, CFSTR("file"),
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
FSRef fs;
if (!CFURLGetFSRef(url, &fs)) return fnfErr; // DEPRECATED API
err = OSACopyScriptingDefinition(&fs, 0, sdef);
} else {
/* ORIGINAL OSACopyScriptingDefinitionFromURL IMPLEMENTATION
GOES HERE */
}
CFRelease(scheme);
return err;
}
-----------------------------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden