Skip to content

Commit

Permalink
Use QStorageInfo as we have now qt5.4+
Browse files Browse the repository at this point in the history
[disk] Use QStorageInfo. Contributes to JB#40595

Signed-off-by: Marko Saukko <marko.saukko@jolla.com>
  • Loading branch information
saukko committed Mar 29, 2018
1 parent 66f8813 commit 8497568
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/diskusage_impl.cpp
Expand Up @@ -39,9 +39,7 @@
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusReply>

#include <sys/statvfs.h>

#include <QStorageInfo>

quint64 DiskUsageWorker::calculateSize(QString directory, QString *expandedPath, bool androidHomeExists)
{
Expand All @@ -61,18 +59,7 @@ quint64 DiskUsageWorker::calculateSize(QString directory, QString *expandedPath,
}

if (directory == "/") {
// Shortcut for getting usage of rootfs
// TODO: Once we have Qt 5.4, use QStorageInfo
struct statvfs stv;
memset(&stv, 0, sizeof(stv));
if (statvfs(directory.toUtf8().constData(), &stv) != 0) {
// Do not make an entry for the usage here
qWarning() << "statvfs() failed on:" << directory;
return 0L;
}
quint64 fsSize = float(stv.f_frsize) * float(stv.f_blocks);
quint64 freeSpace = float(stv.f_frsize) * float(stv.f_bfree);
return fsSize - freeSpace;
return QStorageInfo::root().bytesTotal() - QStorageInfo::root().bytesAvailable();
}

QDir d(directory);
Expand Down

0 comments on commit 8497568

Please sign in to comment.