Qt qtsystems module: QStorageInfo better partitions UUIDs support (Systems: SystemInformation)

Qt qtsystems module provides QSystemStorage class at SystemInfo part.

QSystemStorage class have public invokable method:

Q_INVOKABLE QString uriForDrive(const QString &drive) const;

This method works well (don’t forget about sending correct drive strings with backslash in Windows OSes though), when you want to get information, let’s say, for mounting or umounting filesystems. But you probably could face problem when using this information (uriForDrive) for recognizing removable storage partitions through different operating systems.

// For example, I encountered this task year ago: I had cross-platform app, that synchronizes inner databases between running copies, and that databases stored information about already processed storage partitions. So I wanted to have the same identifiers for, let’s say, fat32-formatted removable devices at any operating system to optimize processing.

Different OSes (expect linux-based) uses their own unique identifiers, even though the most popular filesystem formats supports having partition UUID at their superblock (don’t know about all the filesystem formats though):

Windows uses their own GUIDs for mounting:

mountvol – console application that could show this GUIDs (without params to watch currently mounted)
vol – console application for getting filesystem partition serial number (that updates at reformatting and stored at superblock)

Linux uses native filesystem partition serial numbers:

blkid – console app that could show this UUIDs (needs root rights)

Mac OS X uses UUIDs, that looks similar to native, but don’t tested it at removable devices yet, not sure:

diskutil – console application that could show identifiers that Mac OS X using 

So I suppose it would be nice to implement new QSystemStorage method, similar to uriForDrive(…), that returns OS-independent UUID for filesystem partition (volume), that is stored at filesystem superblock.

// I tried to compile bad hack for my app. Patched qtsystems module uriForDrive(…) windows implementation and it worked (based on GetVolumeInformation function from Windows API. Here is my draft for windows (but, as I said, I guess it should be separated to new method for QSystemStorage:

 █████╗  █████╗  ██╗██████╗  ██████╗ 
███████║███████║╚██║ █████╔╝██║   ██║
██╔══██║██╔══██║ ██║ ╚═══██╗██║▄▄ ██║
██║  ██║██║  ██║ ██║██████╔╝╚██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝ ╚═╝╚═════╝  ╚══▀▀═╝