Using the following code on a Mac running MacOS 10.14 and Xojo 2019r2 my test app tells me that my alias is not an alias. The same happens in a version for 2019r1. The file exists, the Finder shows it to be an Alias, the app correctly shows the path to the original item but cannot detect that the Folderitem itself is an Alias. Am I doing something really stupid ?
[quote=467959:@Horst Jehle]And if you search for TrueChild you can see:
This item was deprecated in version 2019r2.
Please use FolderItem.Child as a replacement.[/quote]
Right. Look at the Documentation for FolderItem.Child.
FolderItem.Child(Name as String, followAlias as Boolean = True) As FolderItem
So: Child("Microsoft Excel Alias", False) should not follow the Alias.
FolderItem.TrueChild(xxx") has to be replaced by FolderItem.Child(“xxx”, False) ’ Get the alias itself
and
FolderItem.Child(xxx") has to be replaced by FolderItem.Child(“xxx”, True) ’ Get the target of the alias
No, if I double click it in Finder Excel is starting. The Aliases was renamed in Finder (Alias was removed from file name).
sh-449:MS Office mcjehle$ ls -al
total 176
drwxr-xr-x@ 10 user admin 320 16 Dez 20:15 .
drwxrwxr-x+ 243 root admin 7776 16 Dez 20:15 …
-rw-r–r--@ 1 user admin 6148 16 Dez 19:03 .DS_Store
-rw-r–r--@ 1 user admin 0 12 Nov 2018 Icon?
-rw-r–r--@ 1 user admin 768 16 Dez 19:04 Microsoft Excel
-rw-r–r--@ 1 user admin 844 16 Dez 19:35 Microsoft OneNote
-rw-r–r--@ 1 user admin 828 12 Nov 2018 Microsoft Outlook
-rw-r–r--@ 1 user admin 844 16 Dez 19:41 Microsoft PowerPoint
-rw-r–r--@ 1 user admin 824 16 Dez 19:41 Microsoft Word
sh-449:MS Office mcjehle$ pwd
/Applications/MS Office
But, when I use this:
f = SpecialFolder.Applications.Child(“MS Office”).Child(“Microsoft Excel Alias”, false)
The alias was detected, when the name of the file ends with “Alias”
drwxr-xr-x@ 10 user admin 320 16 Dez 20:15 .
drwxrwxr-x+ 243 root admin 7776 16 Dez 20:15 …
-rw-r–r--@ 1 user admin 6148 16 Dez 19:03 .DS_Store
-rw-r–r--@ 1 user admin 0 12 Nov 2018 Icon?
-rw-r–r--@ 1 user admin 768 16 Dez 19:04 Microsoft Excel Alias
-rw-r–r--@ 1 user admin 844 16 Dez 19:35 Microsoft OneNote Alias
-rw-r–r--@ 1 user admin 828 12 Nov 2018 Microsoft Outlook Alias
-rw-r–r--@ 1 user admin 844 16 Dez 19:41 Microsoft PowerPoint Alias
-rw-r–r--@ 1 user admin 824 16 Dez 19:41 Microsoft Word Alias
[quote=467982:@Horst Jehle]But, when I use this:
f = SpecialFolder.Applications.Child(“MS Office”).Child(“Microsoft Excel Alias”, false)
The alias was detected, when the name of the file ends with “Alias”[/quote]
just as expected. And yes, since you’re looking for a file named Microsoft Excel Alias, it obviously needs to “end with ‘Alias’”
Then it’s expected that .Child("Microsoft Excel Alias", false) will not find it, since there is no such file with filename Microsoft Excel Alias there.
This was only an example. I have a window where I can drop a file or an Alias and this will not work, because the dropped item is the real folderitem (/Applications/Microsoft Excel.app) not the alias “/Applications/MS Office/Excel Alias”.
So I try to read all files from folder “/Applications/MS Office” and this works now:
var ms as FolderItem
ms = SpecialFolder.Applications.Child(“MS Office”)
If ms.Exists and ms.IsFolder Then
for i as integer = 0 to ms.Count-1
var f as new FolderItem
f = ms.ChildAt(i, false)
if f.IsAlias then
Listbox1.AddRow(f.NativePath)
end if
next
end if
But if I use FileListMBS it doesn’t work. Many it is the same problem like “Drop an alias”.
var ms as FolderItem
ms = SpecialFolder.Applications.Child(“MS Office”)
If ms.Exists and ms.IsFolder Then
var MyFolderList as FileListMBS
MyFolderList = new FileListMBS(ms)
var c as integer = MyFolderList.Count-1
Listbox1.RemoveAllRows
for i as integer = 0 to c
var f as new FolderItem
var n as string
n = MyFolderList.item(i).Name
f = ms.Child(n, false)
if f.IsAlias then
Listbox1.AddRow(f.NativePath)
end if