• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: slash path to alias
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: slash path to alias


  • Subject: Re: slash path to alias
  • From: Axel Luttgens <email@hidden>
  • Date: Tue, 29 Jul 2008 13:57:08 +0200

Le 26 juil. 08 à 00:41, Luther Fuller a écrit :

Thanks. Exactly what I needed. I have been working on a script since about 7am, today. Trying to get it to work in both Leopard and Tiger. All these hours later, I finally found that mailbox paths returned by Tiger's Mail have no colon at the end while those returned by Leopard do.

Hello Luther,

If I may allow...

According to Mail's dictionary, an account has a property "account directory" supposed to provide a file reference in both Tiger and Leopard; so, let's consider following snippet:

	tell application "Mail" to get account directory of first account
	class of result

and let's run it against Leopard's Mail:

	tell application "Mail" to get account directory of first account
	--> file "Disk:folder:...:"
	class of result
	--> «class furl»

and then against Tiger's Mail:

	tell application "Mail" to get account directory of first account
	--> "/path/to/..."
	class of result
	--> Unicode text

That is, Mail's dictionary is lying in Tiger...


So ...

	POSIX path of acntDir
	if (last character of acntDir) = ":" then
		set acntDir to (POSIX file the result) as text
	else
		set acntDir to ((POSIX file the result) as text) & ":"
	end if

And now it works in both Tiger and Leopard.

So, the real cure would be to take care of always handling similar beasts, for example with:


tell application "Mail" to set acntDir to account directory of first account
if class of acntDir is Unicode text then set acntDir to POSIX file acntDir


That way, one is now sure to always act upon file references.


All day poking around in code and the problem was only a colon. Hate it when that happens!

And now, it becomes clear that the ending colon problem isn't related to Mail at all.
(in fact, it makes no sense to speak about Mail returning paths with or without an ending colon: Mail is supposed to return a file reference, and a file reference has no characters...)


The problem is with the way *coercions* of file references (as well as aliases) to strings are handled under Tiger and Leopard when the target is a directory.
In Tiger:


	acntDir as text
	--> "Disk:folder:..."

and in Leopard:

	acntDir as text
	--> "Disk:folder:...:"

BTW, this raises the question: why do you seem to insist on handling files and directories through their textual paths instead of just making use of (supposedly) optimized and (usually) convenient aliases and file references?

HTH,
Axel _______________________________________________
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
References: 
 >slash path to alias (From: Luther Fuller <email@hidden>)
 >Re: slash path to alias (From: "Mark J. Reed" <email@hidden>)
 >Re: slash path to alias (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: Send commands to remote machine with 'do shell script'
  • Next by Date: Re: slash path to alias
  • Previous by thread: Re: slash path to alias
  • Next by thread: Re: slash path to alias
  • Index(es):
    • Date
    • Thread