@samRowlands
Re
Trying to read the contents of an alias always gives me the actual file contents
this code shows
- you CAN get a fodleritem that refers to the alias
- BinaryStream.open seems to ALWAYS resolve alias etc) so yo ucannot open the ALIAS itself as a binary stream
Dim rootPath As String = app.executableFile.parent.parent.nativePath
Dim rpl As Integer = Len( rootPath )
Dim executableAlias As folderItem = app.executableFile.parent.parent.truechild( "Frameworks" ).child( "XojoFramework.framework" ).trueChild( "XojoFramework" )
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
FWIW this C++ code shows that it IS possible to read the binary contents
bool copy(const std::string& oldName, const std::string& newName)
{
bool ok = false;
std::ifstream oldStream(oldName.c_str(), std::ios::binary);
std::ofstream newStream(newName.c_str(), std::ios::binary);
if (oldStream.is_open() && newStream.is_open()) {
newStream << oldStream.rdbuf();
ok = (oldStream.good() && newStream.good());
}
return ok;
}
int main()
{
bool ok = copy( "/Users/npalardy/Desktop/RCI-Mar.pdf alias", "/Users/npalardy/Desktop/RCI-Mar.pdf alias copy" );
std::cout << "Hello, World!\n" << ok ;
return 0;
}
after running that code I get this in terminal (no differences in the contents)
npalardy@server ~ % diff /Users/npalardy/Desktop/RCI-Mar.pdf\ alias /Users/npalardy/Desktop/RCI-Mar.pdf\ alias\ copy
npalardy@server ~ %
Hey Norman,
Thanks for your info mate. The problem was the common enemy of a programmer (tiredness). While both Finder and Xojo identified them as an Alias, the problematic “aliases” were actually Sym Links.
I ended up obtaining the UTI of the “Alias”, if it is a “Bookmark” you can read its contents, but if it is a “Symbolic Link”, you have to use a different API to read the contents.
Both I found that Xojo auto resolves aliases dropped onto the app icon, dropped into a window and pasted from the clipboard. I’ve solved the latter two, but today will experiment with capturing the apple event “odoc”.
yeah a sym link is a much different beast than an alias