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. Does Qt have a mechanism like the `file` utility to read info about a file?

Does Qt have a mechanism like the `file` utility to read info about a file?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 126 Views
  • 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.
  • Petross404_Petros SP Offline
    Petross404_Petros SP Offline
    Petross404_Petros S
    wrote on last edited by
    #1

    Hi all, I hope you are doing well.

    I need to read information about some executables that the user loads on KDbg. Usually on Linux this can be done by running file executable and various info will be returned.

    Example:

    $ file test
    test: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
    
    $ file ri-t.o
    ri-t.o: ELF 64-bit LSB relocatable, UCB RISC-V, RVC, double-float ABI, version 1 (SYSV), not stripped
    

    I could use QProcess::start to run file ... but I need a portable way or this doesn't happen at all. I want to read the CPU the executable targets and possibly other stuff (ie if it's stripped etc).

    Please tell me I can do this. Thank you for your time.

    JonBJ 1 Reply Last reply
    0
    • Petross404_Petros SP Petross404_Petros S

      Hi all, I hope you are doing well.

      I need to read information about some executables that the user loads on KDbg. Usually on Linux this can be done by running file executable and various info will be returned.

      Example:

      $ file test
      test: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
      
      $ file ri-t.o
      ri-t.o: ELF 64-bit LSB relocatable, UCB RISC-V, RVC, double-float ABI, version 1 (SYSV), not stripped
      

      I could use QProcess::start to run file ... but I need a portable way or this doesn't happen at all. I want to read the CPU the executable targets and possibly other stuff (ie if it's stripped etc).

      Please tell me I can do this. Thank you for your time.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Petross404_Petros-S
      No, Qt does not have a utility like file.

      Unless it has changed since my day, file uses /etc/magic for its information. It looks at first-ish bytes in file. (It might have some extra hardcoded stuff, I don't know.) You could write this effectively from a Qt program if that's what you wanted to do.

      I want to read the CPU the executable targets and possibly other stuff (ie if it's stripped etc).

      That can probably be done other ways. ld gets involved in that, at least for its own architecture.

      1 Reply Last reply
      4
      • Petross404_Petros SP Offline
        Petross404_Petros SP Offline
        Petross404_Petros S
        wrote on last edited by
        #3

        Sure enough, the last one is a very good approach, but when KDbg will run under Windows I will have problem. Anyway, I will mark this as solved, since there is nothing more to be done. Qt just doesn't have this functionality.

        Thank you for your time.

        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