How to determine the total space, used space and fileformat of an SD Card In Qt??

  • I am working on an app where I have to display the drive name, drive format, total space, used space and the write protect state of an SD Card.

    @typedef struct SDVisualInfo{
    QString strDriveName;
    QString strFileSystem;
    QString strTotal;
    QString strUsed;
    QString strProtectStatus;

    stSDVsInfo newData;
    newData.strDriveName = deviceData->m_strPath; // Device data is a class which gives me the path and write protect state of the drive
    if ( deviceData->m_bReadable == true && deviceData->m_bWritable == true )
    newData.strProtectStatus= "Write Protect Disabled";
    else if ( deviceData->m_bReadable == true)
    newData.strProtectStatus= "Write Protect Enabled";

    QList <stSDVsInfo> m_SDInfoList;

    This gives me the drivepath, writeprotect state but I am unable to find the total space, used space and filesystem format of the SD card. Is their a way(Qt Class) which can help me get the above mentioned requirements?

  • Lifetime Qt Champion


    The api's to get these informations are OS specific, you have to write the code yourself. Look at statvfs for *nix and GetDiskFreeSpaceEx for Windows.

    Hope it helps

  • Moderators

    As mentioned in your other topic, you can use Qt classes for that (well, almost-Qt. They are outside Qt5 at the moment, AFAIK): "QtDriveInfo": and "QtStorageInfo": classes.

    Also, "this discussion": on dev ML might be of interest.

Log in to reply