Re: Best practices
Re: Best practices
- Subject: Re: Best practices
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 17 Feb 2011 08:02:49 -0500
POSIX paths are nice in some ways, but tricky as well. They're not
really *just* strings, because they have non-stringlike semantics.
If your app treats them as black boxes, fine, but if it cares e.g.
whether two paths refer to the same file, then you can't just do a
string comparison. Forget symbolic links or pathological things like
"../././/..//./.."; even just recognizing that "foo" and "./foo" are
the same file (or that "the directory part of 'foo'" is somehow ".")
takes an amount of care and code. Are doubled slashes OK? Do
directory paths end in "/"? That matters when you have directory path
d and file name f and want to put them together - is it just d&f or
is it d&"/"&f? What if d is just "/"?
It's nice to have an abstraction layer that takes care of those
details for you. AS doesn't really have one of those, so you wind up
using external apps that do.
On Thursday, February 17, 2011, Emmanuel LEVY <email@hidden> wrote:
> Sorry, I'm not sure at all that all apps like "posix file f".
>
> We don't use any app actually - none is fast and reliable enough for us, including System Events [1] - only StandardAdditions. "info for" and the like work well with "posix file f".
>
> posix paths are lovely, because, well, you just manipulate strings, specifying a file's container folder is a mere regular expression, etc.
>
> Emmanuel
>
> [1] I posted here our instead-of-System-Events osax, Files.osax.
>
> On Feb 16, 2011, at 11:03 PM, Shane Stanley wrote:
>
>
> On 17/2/11 1:56 AM, "Emmanuel LEVY" <email@hidden> wrote:
>
>
> I've got one, if you like.
>
> Never use anything else than posix paths. Whenever some command
> doesn't like posix paths, just insert "posix file" before the posix
> path.
>
>
> Being consistent has merit. Are you sure all apps that require aliases will
> accept furls instead?
>
> --
> Shane Stanley <email@hidden>
> 'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>
>
>
> _______________________________________________
> 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
>
>
> _______________________________________________
> 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
>
--
Mark J. Reed <email@hidden>
_______________________________________________
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