Re: Finder "duplicate" requirements
Re: Finder "duplicate" requirements
- Subject: Re: Finder "duplicate" requirements
- From: Shane Stanley <email@hidden>
- Date: Mon, 29 Jun 2015 10:20:39 +1000
On 29 Jun 2015, at 3:15 am, Jon Pugh <email@hidden> wrote:
>
> there’s nothing wrong with using POSIX paths as long as you know what you’re doing
Indeed, there's a lot to be said for them. One of the frustrations of HFS paths is manipulating them: relying on text item delimiters for simple things like extracting extensions and parts of a path (or, shudder, reversing character lists and looking for offsets), and having to check for a trailing colon before adding a file name or subpath. There's nothing wrong with using HFS paths as long as you know what you're doing. There are traps lurking in both HFS and POSIX paths, and they often trip up people used to one or the other when they need to change sides.
FWIW, I think this is one of the nice things about using ASObjC: path manipulation methods. If you want the name, you ask for the lastPathComponent(). You want the extension, it's pathExtension(). You want to add a name or subpath to a folder path, you use stringByAppendingPathComponent: and never have to worry about whether there was a trailing delimiter or not -- it's taken care of for you. Similarly stringByDeletingLastPathComponent(), stringByDeletingPathExtension() and stringByExpandingTildeInPath() -- they do just what it says on the tin.
They're long names, but it often amounts to less typing, and they're hard to fault in terms of readability. And you can't really go wrong -- you can't accidentally leave text item delimiters in an odd state, or forget hat there's already a trailing delimiter and end up with consecutive colons. Path manipulation becomes one less thing to worry about.
Until you go to pass anything to an app, regardless of the type of path...
--
Shane Stanley <email@hidden>
<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