7 #include <sys/statvfs.h>
21 ULARGE_INTEGER freeBytesAvailable, totalNumberOfBytes, totalFreeBytes;
26 int wchars_num = MultiByteToWideChar( CP_UTF8 , 0 , path.c_str() , -1, NULL , 0 );
27 wchar_t* wstr =
new wchar_t[wchars_num];
28 MultiByteToWideChar( CP_UTF8 , 0 , path.c_str() , -1, wstr , wchars_num );
29 if(GetDiskFreeSpaceEx(wstr, &freeBytesAvailable, &totalNumberOfBytes, &totalFreeBytes)) {
30 out.
totalSize = totalNumberOfBytes.QuadPart;
31 out.
freeSize = freeBytesAvailable.QuadPart;
35 if(GetDiskFreeSpaceEx(path.c_str(), &freeBytesAvailable, &totalNumberOfBytes, &totalFreeBytes)) {
36 out.
totalSize = totalNumberOfBytes.QuadPart;
37 out.
freeSize = freeBytesAvailable.QuadPart;
42 struct statvfs fiData;
43 if(statvfs(path.c_str(), &fiData) >= 0) {
unsigned long long freeSize
unsigned long long totalSize
DiskStatus getDiskStatus(const std::string &path) const
Get status of the disk behind the given path.
double getDiskFreePercent(const std::string &path) const
Get free fraction of the disk behind the given path.