Re: Converting Xcode paths to usable paths
Re: Converting Xcode paths to usable paths
- Subject: Re: Converting Xcode paths to usable paths
- From: Steve Mills <email@hidden>
- Date: Tue, 01 Dec 2009 15:50:45 -0600
On Dec 1, 2009, at 15:31:31, Jens Alfke wrote:
> The ".."s may look annoying to you, but that _is_ a perfectly valid POSIX path.
Maybe so, but LOTS of things can't deal with them in a path. Try this incredibly simple example and you'll see what I mean (it's weird, but should work on any standard OS X installation). It gets stuck on the first ".." and ends up revealing /Applications/TextEdit.app/Contents/MacOS/ instead:
tell application "Finder"
reveal POSIX file "/Applications/TextEdit.app/Contents/MacOS/../../../Preview.app"
end tell
Since AppleScript/Xcode/Finder/something can't handle this conversion for the user, I ended up writing it into my script, which I'll supply here for anyone else who needs it.
on ResolveXcodePath(goofyPath)
--Turn goofy Xcode bidirectional path (/puke/../barf) into a real path:
set sd to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"/"}
set hunks to every text item of goofyPath
set newHunks to {}
repeat with hunk in hunks
set hunkText to hunk as text
if hunkText is ".." then
if (count items of newHunks) > 1 then
set newHunks to items 1 thru -2 of newHunks
else
set newHunks to {}
end if
else
set end of newHunks to hunkText
end if
end repeat
set goofyPath to newHunks as text
set AppleScript's text item delimiters to sd
return goofyPath
end ResolveXcodePath
Steve Mills
Drummer, Mac geek
http://sjmills5.home.mchsi.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden