Re: Resolving an alias
Re: Resolving an alias
- Subject: Re: Resolving an alias
- From: Emmanuel LEVY <email@hidden>
- Date: Fri, 30 Oct 2009 17:12:28 +0100
We think it's better to work with posix paths rather than the native
mac types for files.
(For those interested, the strong reason is that alias fails at making
the difference between two mounted volumes or two shared volumes with
the same name).
If you work with posix paths, here's our set of core handlers for the
question you ask:
on dereferencepath(f) -- resolving an alias
try
return POSIX path of (POSIX file f as alias)
end try
end dereferencepath
on validlink(x) -- is that a symbolic link?
dereferencepath(x) is not in {x, x & "/"}
end validlink
on validfolder(x) -- is that a folder?
try
return ((POSIX path of (POSIX file x as alias)) ends with "/")
end try
return false
end validfolder
on validalias(x) -- is that a valid reference to whatever but to
something?
try
POSIX file x as alias
return true
end try
return false
end validalias
Emmanuel
Satimage-software, and Quomodo
On Oct 30, 2009, at 4:34 PM, Thomas Fischer wrote:
Sander,
[...]
If somebody drops anything on your AppleScript app, your on handler
receives a list of aliases and I was wondering how I could decide if
they were files, folders or anything else.
tell me
info for someAlias
end
No, this doesn't quite do what I need, unless I go into some
additional analysis of the info record I get. I get a folder flag,
but would need to check if the alias is e.g. for a file or an
internet location. And it definitely doesn't give me a hold of the
original file.
Deivy's method
tell application "Finder" to class of (get properties of l)
gets the correct class if this is all I need.
Thomas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript-
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