GetTrueFolderitem bug?

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=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.

for me it works.

[code] dim f1 as FolderItem = SpecialFolder.Desktop.Child(“test Alias”)
dim n1 as string = f1.name
dim p1 as string = f1.NativePath

dim f2 as FolderItem = SpecialFolder.Desktop.TrueChild(“test Alias”)
dim n2 as string = f2.name
dim p2 as string = f2.NativePath

dim f3 as FolderItem = GetFolderItem("/Users/cs/Desktop/test Alias", FolderItem.PathTypeNative)
dim n3 as string = f3.name
dim p3 as string = f3.NativePath

dim f4 as FolderItem = GetTrueFolderItem("/Users/cs/Desktop/test Alias", FolderItem.PathTypeNative)
dim n4 as string = f4.name
dim p4 as string = f4.NativePath
[/code]

You can try with your own test alias on desktop.

I tried myself, and got exactly the same path.

Now I found a simple method with AppleScript :

on run {value1} return POSIX path of value1 end run

Drag into the project, pass the full path of the alias, get the resolved path in return.

[quote=163552:@Christian Schmitz]for me it works.

[code] dim f1 as FolderItem = SpecialFolder.Desktop.Child(“test Alias”)
dim n1 as string = f1.name
dim p1 as string = f1.NativePath

dim f2 as FolderItem = SpecialFolder.Desktop.TrueChild(“test Alias”)
dim n2 as string = f2.name
dim p2 as string = f2.NativePath

dim f3 as FolderItem = GetFolderItem("/Users/cs/Desktop/test Alias", FolderItem.PathTypeNative)
dim n3 as string = f3.name
dim p3 as string = f3.NativePath

dim f4 as FolderItem = GetTrueFolderItem("/Users/cs/Desktop/test Alias", FolderItem.PathTypeNative)
dim n4 as string = f4.name
dim p4 as string = f4.NativePath
[/code]

You can try with your own test alias on desktop.[/quote]

I tried your code and it as suspected, FolderItem.TrueChild works, but GetTrueFolderItem() fails.
When calling FolderItem.TrueChild (f2 in your code) I get the name and native path of the alias item,
when calling GetTrueFolderItem() (f4 in your code) I get the name and native path of the ORIGINAL item.

Now I’m surprised it works for you…

[quote=163552:@Christian Schmitz]for me it works.
You can try with your own test alias on desktop.[/quote]

Aren’t you using Mavericks, or an older version of Yosemite ? Under 10.10.2, I assure you it does not.

for me it works. If not, it should be reported and fixed as soon as possible.

Reported as a bug:
<https://xojo.com/issue/37975>

Already closed as Not Reproducible :frowning:

Sorry but I cannot reproduce it on 10.9 or 10.10 and I basically duplicated your set up with a desktop alias pointing to a file elsewhere
More details on how to reproduce what your seeing could reverse that

The weird thing is your example works for me too.
But I still have my example failing and I can reproduce the failure again:

you know difference between alias (from Mac OS) and symlink (from Unix)?

Yes Christian, I know the difference, but these are usually treated at the same way. And btw GetTrueFolderitem() used to work the same for both. I guess the API used was at the level where the OS provide this equivalence.

Anyway now, it seems the problem is just that GetTrueFolderitem() doesn’t recognize anymore SOFT links (created with ln -s) as aliases. But I’m sure this used to work in past…

As Norman found, turned out the problem is using Folderitem.NativePath vs Folderitem.Shellpath.
With the latter works, but not with the first.