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;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;
m_SDInfoList.append(newData);@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?
-
Hi,
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
-
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":https://gitorious.org/qdrive and "QtStorageInfo":http://qt.gitorious.org/qt/qtsystems classes.
Also, "this discussion":http://comments.gmane.org/gmane.comp.lib.qt.devel/10164 on dev ML might be of interest.