Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. store and read shorcut/alias/symlink files across platforms
Qt 6.11 is out! See what's new in the release blog

store and read shorcut/alias/symlink files across platforms

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 550 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kazaak
    wrote on last edited by kazaak
    #1

    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?

    Pl45m4P 1 Reply Last reply
    0
    • K kazaak

      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?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @kazaak

      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


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      K 1 Reply Last reply
      0
      • Pl45m4P Pl45m4

        @kazaak

        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

        K Offline
        K Offline
        kazaak
        wrote on last edited by
        #3

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

        Pl45m4P 1 Reply Last reply
        0
        • K kazaak

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

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @kazaak

          What about QUrl?


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kazaak
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved