USB storage cross-platform support?



  • I'm writing a small Linux app that will need to store some data on a removable USB flash drive, reusing it from time to time. To be more precise, I will need to:

    1. Detect if/when a new USB (storage) device get connected to the system
    2. Enumerate the connected USB devices (to search for the right USB drive)
    3. Read the Serial_Number/ID/Name of the connected USB devices (in order to identify the right device)
    4. Read/Write files from/to the USB storage device

    That is: it is not just a matter to read/write from/to a known device (a device listed in /dev and of known ID/Name). I also need to query the host system for some info about the available devices.

    Of course, I can rely on udev (and maybe HAL and/or DBUS) to perform such a task but this would end up in a quite Linux-specific solution written on top of a cross-platform library (Qt itself). Not very clever...

    So, I wonder if Qt has its own (cross-platform) tools for managing the USB storage devices (just USB removable hard disks, not USB interactive HID peripherals). I was unable to find any mention to USB in the Qt Documentation and forums. Does anybody has any info/link/suggestion?

    Thanks



  • I think the reason you find no mention of USB is because... well it is generic storage, it doesn't matter if it is P-ATA, S-ATA, USB, Firewire, Thunderbolt or whatever, it is just storage. This is a responsibility of the OS to provide in the form of generic storage, and that is what Qt uses. There are ways to determine whether a storage device is USB or not, but those are platform specific, you will have to create different platform specific solutions and chose the right one during compilation using preprocessor conditional directives.



  • Thanks ddriver. You confirmed my understanding of this topic. I will go on with a Linux-specific solution for the moment.



  • Note that there is code in QtMobility (that should work just fine on the desktop as well) to enumerate system drives.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.