Re: Preventing POSIX File to Alias Conversion from Inserting Leading Colon
Re: Preventing POSIX File to Alias Conversion from Inserting Leading Colon
- Subject: Re: Preventing POSIX File to Alias Conversion from Inserting Leading Colon
- From: "Mark J. Reed" <email@hidden>
- Date: Sun, 16 Aug 2009 19:01:08 -0400
First, the conversion is correct. Since there's no leading / on the
POSIX path, it's relative to the current working directory; the way to
get the same relative nature in an HFS path is to put a leading colon
on it.
But the current working directory is not, in general, well-defined for
an AppleScript process running out of Script Editor. Better to use
use one of the "path to" commands to locate the folder containing the
".background" subfolder, or else use an absolute POSIX path.
In this case, I'm not sure why the version of the HFS path with no
leading colon works; probably has something to do with being inside a
"tell disk" block.
Absolute POSIX: /dir/subdir/file
Absolute HFS: Volume:dir:subdir:file
Relative POSIX: subdir/file
Relative HFS: :subdir:file
On Sun, Aug 16, 2009 at 6:05 PM, Grant Erickson<email@hidden> wrote:
> Is there a way to prevent POSIX file from inserting a leading colon to
> relative paths, whether specified as literals or read as a value from
> elsewhere?
>
> I have the following script snippet:
>
> ...
>
> tell theDisk
> if 0 is equal to 1 then
> -- Fails due to ':' insertion
> set theBackground to POSIX file ".background/background.png"
> else
> -- Works
> set theBackground to file ".background:background.png"
> end if
> end tell
>
> set background picture of theOptions to theBackground
>
> ...
>
> If I convert the POSIX path, I end up with ":.background:background.png"
> which doesn't exist. Whereas, the string literal
> ".background:background.png" works correctly.
>
> Ultimately, the POSIX literal will be replaced by a value accessed from a
> property list record:
>
> set theBackground to (|Background| of (|Options| of theView)) as POSIX
> file
>
> I can, of course, coerce the converted path to text, change the text item
> delimiters, chop the first item and coerce it back to a file; however, that
> seems like an unseemly solution.
>
> Regards,
>
> Grant
>
>
> _______________________________________________
> 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