store and read shorcut/alias/symlink files across platforms
-
I developed a desktop app that as part of its operation creates shorcut/alias/symlink files that point to a location on a network drive. If I create open these links on the same platform they were created (using QFile::link()) they open fine. There is a cross-platform way to write the links, but not read them. Do I have to create my own approach or is there a way to read an lnk file on mac and open it appropriately (I can't even read the file to do much with it and binary reading seems hacky) and vice versa for windows reading aliases?
-
I developed a desktop app that as part of its operation creates shorcut/alias/symlink files that point to a location on a network drive. If I create open these links on the same platform they were created (using QFile::link()) they open fine. There is a cross-platform way to write the links, but not read them. Do I have to create my own approach or is there a way to read an lnk file on mac and open it appropriately (I can't even read the file to do much with it and binary reading seems hacky) and vice versa for windows reading aliases?
Why do you want to read lnk on Mac?!
Use Mac links on Mac and Windows lnk on Windows?!You also don't build .dlls for Linux or .exe for Mac... Some systems have their default formats...
Use OS compiler macros to detect the host system and then use the appropriate code
-
Why do you want to read lnk on Mac?!
Use Mac links on Mac and Windows lnk on Windows?!You also don't build .dlls for Linux or .exe for Mac... Some systems have their default formats...
Use OS compiler macros to detect the host system and then use the appropriate code
@Pl45m4 I’m looking for a robust solution to store a network path. Using QFile::Link() and QFileInfo:toLocalFile() saves me a lot of checking and ensuring the paths are the right separator with the right encoding and format and can convert to valid path when I want to open the file. An existing approach with Qt saves me those headaches.
-
@Pl45m4 I’m looking for a robust solution to store a network path. Using QFile::Link() and QFileInfo:toLocalFile() saves me a lot of checking and ensuring the paths are the right separator with the right encoding and format and can convert to valid path when I want to open the file. An existing approach with Qt saves me those headaches.
-
The ‘items’ in my application need to know if they’re pointing to a image, video, document, website, or other file and treating the shortcut like a file helps me a lot with this. Even with QUrl I’d still have to flag the original path as windows or Mac to know how to convert it. With shortcut/alias I would know where I’m starting from without needing another flag. It would be nice if QFile:link() could go cross platform from link back to target.