6 #  include <QFileInfoList> 
    7 #  include <qt_windows.h> 
    8 static constexpr 
int BUFFER_SIZE = 255;
 
   15     m_process = 
new QProcess(
this);
 
   16     connect(m_process, SIGNAL(readyRead()), 
this, SLOT(handleReadyRead()));
 
   30     STORAGE_PROPERTY_QUERY query;
 
   31     query.PropertyId = StorageDeviceProperty;
 
   32     query.QueryType = PropertyStandardQuery;
 
   35     name = 
"\\\\.\\" + name.left(name.length() - 1);
 
   37     HANDLE hDevice = CreateFileW(
 
   38         name.toStdWString().c_str(),
 
   39         GENERIC_READ | GENERIC_WRITE,
 
   40         FILE_SHARE_READ | FILE_SHARE_WRITE,
 
   51     STORAGE_DESCRIPTOR_HEADER *pHeader = (STORAGE_DESCRIPTOR_HEADER *)
malloc(
sizeof(STORAGE_DESCRIPTOR_HEADER));
 
   58     BOOL bResult = DeviceIoControl(
 
   60         IOCTL_STORAGE_QUERY_PROPERTY,
 
   64         sizeof(STORAGE_DESCRIPTOR_HEADER),
 
   75     PSTORAGE_DEVICE_DESCRIPTOR pDev = (STORAGE_DEVICE_DESCRIPTOR *)
malloc(pHeader->Size);
 
   78         IOCTL_STORAGE_QUERY_PROPERTY,
 
   89     if(pDev->BusType == BusTypeUsb)
 
  107     for(
const QFileInfo &fin : QDir::drives())
 
  109         const QString &path = fin.absolutePath();
 
  110         const int type = GetDriveTypeW(path.toStdWString().c_str());
 
  111         if(type == DRIVE_REMOVABLE)
 
  115         else if(type == DRIVE_FIXED)
 
  127         ULARGE_INTEGER freeAvailable;
 
  128         ULARGE_INTEGER totalNumberOfBytes;
 
  129         ULARGE_INTEGER totalNumberOfFreeBytes;
 
  131         if(GetDiskFreeSpaceExW(path.toStdWString().c_str(), &freeAvailable, &totalNumberOfBytes, &totalNumberOfFreeBytes))
 
  133             const qint64 available = freeAvailable.QuadPart / 
TTK_SN_GB2B;
 
  134             const qint64 total = totalNumberOfBytes.QuadPart / 
TTK_SN_GB2B;
 
  150             DWORD serialNumber = 0;
 
  152             DWORD fileSysFlags = 0;
 
  154             WCHAR dirveName[BUFFER_SIZE];
 
  155             WCHAR fileSysTypeName[BUFFER_SIZE];
 
  157             if(GetVolumeInformationW(
 
  158                 item.
m_path.toStdWString().c_str(),
 
  167                 item.
m_name = QString::fromStdWString(dirveName);
 
  174     connect(m_process, SIGNAL(finished(
int)), &loop, SLOT(quit()));
 
  177     m_process->start(
"df", {
"-h"});
 
  184 static int driveSizeToNumber(QString &v)
 
  191     else if(v.endsWith(
"M"))
 
  199 void MusicDeviceInfoModule::handleReadyRead()
 
  201     while(!m_process->atEnd())
 
  203         const QString &result = QString::fromLocal8Bit(m_process->readLine());
 
  204         if(result.startsWith(
"/dev/sd"))
 
  206             QString dev, use, total, path;
 
  209             const QStringList &list = result.split(
TTK_SPACE);
 
  210             for(
int i = 0; i < list.count(); ++i)
 
  212                 const QString &data = list.at(i).trimmed();
 
  237             if(path.startsWith(
"/media/"))
 
MusicDeviceInfoItemList m_items
 
int exec(ProcessEventsFlags flags=AllEvents)
 
#define INVALID_HANDLE_VALUE
 
#define QtProcessVoidConnect(p, q, f, s)
Process error void connect. 
 
The class of the ttk event loop. 
 
The class of the system device info item. 
 
bool disksProperty(const QString &drive) const 
 
MusicDeviceInfoItemList removableDrive()
 
MusicDeviceInfoModule(QObject *parent=nullptr)