KySdkDisk3
Class for generating d-bus signals for disk information
Usage
#include <kysdkdbus.h>
KySdkDisk.3
Overview
The KySdkDisk class is mainly used to generate D-Bus signals for disk list, number of sectors, bytes per sector, capacity, model, serial number, number of sub-partitions, type, and firmware version information.
This class inherits from QObject.
Public slots
QStringList getDiskList () const
Get the list of all disks.
Return value:
QStringList-
List of disks, each string represents the absolute path of a disk
unsigned int getDiskSectorSize (const QString diskname) const
Get the number of bytes per sector of the disk.
Parameters:
diskname-
Specify the disk name, should be an absolute path such as /dev/sda
Return value:
- unsigned int
-
Number of bytes per sector
double getDiskTotalSizeMiB (const QString diskname) const
Get the disk capacity.
Parameters:
diskname-
Specify the disk name, should be an absolute path such as /dev/sda
Return value:
double-
Disk capacity in MiB
QString getDiskModel (const QString diskname) const
Get the disk model.
Parameters:
diskname-
Specify the disk name, should be an absolute path such as /dev/sda
Return value:
QString-
Disk model
QString getDiskSerial (const QString diskname) const
Get the disk serial number.
Parameters:
diskname-
Specify the disk name, should be an absolute path such as /dev/sda
Return value:
QString-
Disk serial number
unsigned int getDiskPartitionNums (const QString diskname) const
Get the number of sub-partitions under the disk/partition.
Parameters:
diskname-
Specify the disk name, should be an absolute path such as /dev/sda
Return value:
- unsigned int
-
Number of sub-partitions under this disk/partition
QString getDiskType (const QString diskname) const
Get the disk type.
Parameters:
diskname-
Specify the disk name, should be an absolute path such as /dev/sda
Return value:
QString-
Disk type, SSD or HDD or Hybrid
QString getDiskVersion (const QString diskname) const
Get the disk firmware version information.
Parameters:
diskname-
Specify the disk name, should be an absolute path such as /dev/sda
Return value:
QString-
Firmware version information
unsigned long long getDiskSectorNum (const QString diskname) const
Get the number of disk sectors.
Parameters:
diskname-
Specify the disk name, should be an absolute path such as /dev/sda
Return value:
- unsigned long long
-
Number of sectors
Example usage
#include <kysdkdbus.h>
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
KySdkDisk diskInfo;
// Get disk list
QStringList disks = diskInfo.getDiskList();
// Get information of the first disk
if (!disks.isEmpty()) {
QString diskName = disks.first();
QString model = diskInfo.getDiskModel(diskName);
double size = diskInfo.getDiskTotalSizeMiB(diskName);
// ... use other methods
}
return 0;
}