[quote=163541:@Massimo Valle]I used to get alias files (links in Windows) with GetTrueFolderItem(), but it seems to me it’s not working properly anymore.
OS X 10.10.2 - Xojo 2014r3.2
Example:
I have the following file (absolute path):
/Users/massimo/Desktop/Archive/Test.zip
Then I have an alias pointing to the above file named:
/Users/massimo/Desktop/Test.zip
From Xojo:
dim f as folderItem = GetTrueFolderItem("/Users/massimo/Desktop/Test.zip", Folderitem.PathTypeNative)
now inspecting f, it points to the original file (the alias was resolved).
Is this a bug?
Someone else can confirm this?[/quote]
I read somewhere in this forum, as well as in other forums, that resolving aliases was broken in Yosemite. This probably calls for some declare.
Alternatively, I found this bash script that complains about Osascript, but does provide the proper path in the end :
#!/bin/sh
if [ $# -eq 0 ]; then
echo ""
echo "Usage: apath alias"
echo " where alias is an alias file."
echo " Returns the file path to the original file referenced by a"
echo " Mac OS X GUI alias. Use it to execute commands on the"
echo " referenced file. For example, if aliasd is an alias of"
echo " a directory, entering"
echo ' % cd `apath aliasd`'
echo " at the command line prompt would change the working directory"
echo " to the original directory."
echo ""
fi
if [ -f "$1" -a ! -L "$1" ]; then
item_name=`basename "$1"`
item_parent=`dirname "$1"`
item_parent="`cd \"${item_parent}\" 2>/dev/null && pwd || echo \"${item_parent}\"`"
item_path="${item_parent}/${item_name}"
line_1='tell application "Finder"'
line_2='set theItem to (POSIX file "'${item_path}'") as alias'
line_3='if the kind of theItem is "alias" then'
line_4='get the posix path of (original item of theItem as text)'
line_5='end if'
line_6='end tell'
orig=`osascript -e "$line_1" -e "$line_2" -e "$line_3" -e "$line_4" -e "$line_5" -e "$line_6"`
echo "$orig"
fi
Save as mycommand.sh and for use in terminal or shell go
./mycommand.sh alias
Here is a sample result I got :
Mitchs-iMac:desktop Mitch$ ./goo.sh Xojo2015R1b5
2015-01-31 12:06:12.110 osascript[1963:513606] Error loading /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: dlopen(/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions, 262): no suitable image found. Did find:
/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: mach-o, but wrong architecture
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/QXPScriptingAdditions.osax" declares no loadable handlers.
/Applications/Xojo 2015r1b5/Xojo.app
Mitchs-iMac:desktop Mitch$
The last line is the path to the original file.