Trying to read the contents of an alias file (not the linked file), and binarystream / textinputstream return the contents of the linked file, not the alias.
Even doing “cat” on the terminal to display the contents of the alias via the terminal returns the contents of the linked file, not the link. Some for other apps.
I have verified that I am trying to read the alias as the folderitem.length is 30 bytes, instead of 2.7 MB.
Am I really just too tired and missing something, or has this changed recently?
Hmmm… In that simple test it does also work here… So what is going on in my app.
Edit 2: Take that back! For some reason I was using the folderitem.length as a gauge of how much data to read. Once I updated it to use the stream length…
Edit 3: This updated code also shows paths to confirm.
Try this code.
dim rootPath as string = app.executableFile.parent.parent.nativePath
dim rpl as integer = len( rootPath )
dim executableAlias as folderItem = app.executableFile.parent.parent.child( "Frameworks" ).child( "XojoFramework.framework" ).trueChild( "XojoFramework" )
dim executableFile as folderItem = executableAlias.parent.child( executableAlias.name )
dim fileStreamPath as string = executableFile.nativePath
fileStreamPath = right( fileStreamPath, len( fileStreamPath ) - rpl )
dim fileStream as binaryStream = binaryStream.open( executableFile, false )
dim fileStreamLength as Uint64 = fileStream.length
dim fileContents as string = fileStream.read( fileStream.length )
fileStream.close
dim aliasStreamPath as string = executableAlias.nativePath
aliasStreamPath = right( aliasStreamPath, len( aliasStreamPath ) - rpl )
dim aliasStream as binarystream = binaryStream.open( executableAlias, false )
dim aliasStreamLength as Uint64 = aliasStream.length
dim aliasContents as string = aliasStream.read( aliasStream.length )
aliasStream.close
break
Awake now and certainly more lucid. So yes, according to Xojo and to the Finder, Aliases and Symbolic Links are both Aliases, but under the hood they’re not.
Reading the UTI from the Alias tells me the difference, then I can use other API to read the contents of the Symbolic Link. Just not a Xojo “stream”. I get the feeling that this is not Xojo’s fault, it’s just how the OS “works”.
Yes on macOS. It’s just that Finder and Xojo lump them and bookmarks together as Aliases, so you may have already encountered them, just never knew. They only cause problems for me, because I was trying to get at the data of the alias and it was failing, because it is a Symbolic Link and I needed to use an alternative method for it.