summaryrefslogtreecommitdiffstats
path: root/rbutil
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/rbutilqt/base/utils.cpp57
-rw-r--r--rbutil/rbutilqt/base/utils.h2
-rw-r--r--rbutil/rbutilqt/base/zipinstaller.cpp3
-rw-r--r--rbutil/rbutilqt/sysinfo.cpp4
4 files changed, 52 insertions, 14 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp
index 3447320e11..fe35f0c295 100644
--- a/rbutil/rbutilqt/base/utils.cpp
+++ b/rbutil/rbutilqt/base/utils.cpp
@@ -135,6 +135,51 @@ QString Utils::resolvePathCase(QString path)
}
+QString Utils::filesystemType(QString path)
+{
+#if defined(Q_OS_LINUX)
+ FILE *mn = setmntent("/etc/mtab", "r");
+ if(!mn)
+ return QString("");
+
+ struct mntent *ent;
+ while((ent = getmntent(mn))) {
+ if(QString(ent->mnt_dir) == path) {
+ endmntent(mn);
+ LOG_INFO() << "device type is" << ent->mnt_type;
+ return QString(ent->mnt_type);
+ }
+ }
+ endmntent(mn);
+#endif
+
+#if defined(Q_OS_MACX) || defined(Q_OS_OPENBSD)
+ int num;
+ struct statfs *mntinf;
+
+ num = getmntinfo(&mntinf, MNT_WAIT);
+ while(num--) {
+ if(QString(mntinf->f_mntonname) == path) {
+ LOG_INFO() << "device type is" << mntinf->f_fstypename;
+ return QString(mntinf->f_fstypename);
+ }
+ mntinf++;
+ }
+#endif
+
+#if defined(Q_OS_WIN32)
+ wchar_t t[64];
+ memset(t, 0, 32);
+ if(GetVolumeInformationW((LPCWSTR)path.utf16(),
+ NULL, 0, NULL, NULL, NULL, t, 64)) {
+ LOG_INFO() << "device type is" << t;
+ return QString::fromWCharArray(t);
+ }
+#endif
+ return QString("-");
+}
+
+
QString Utils::filesystemName(QString path)
{
QString name;
@@ -218,18 +263,10 @@ qulonglong Utils::filesystemTotal(QString path)
}
-qulonglong Utils::filesystemClusterSize(QString path)
-{
- qulonglong size = filesystemSize(path, FilesystemClusterSize);
- LOG_INFO() << "cluster size for" << path << size;
- return size;
-}
-
-
qulonglong Utils::filesystemSize(QString path, enum Utils::Size type)
{
qulonglong size = 0;
-#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
+#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
// the usage of statfs() is deprecated by the LSB so use statvfs().
struct statvfs fs;
int ret;
@@ -281,7 +318,7 @@ qulonglong Utils::filesystemSize(QString path, enum Utils::Size type)
//! \brief searches for a Executable in the Environement Path
QString Utils::findExecutable(QString name)
{
- //try autodetect tts
+ //try autodetect tts
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX) || defined(Q_OS_OPENBSD)
#if QT_VERSION >= 0x050e00
QStringList path = QString(getenv("PATH")).split(":", Qt::SkipEmptyParts);
diff --git a/rbutil/rbutilqt/base/utils.h b/rbutil/rbutilqt/base/utils.h
index ca9c1d61af..f46f713525 100644
--- a/rbutil/rbutilqt/base/utils.h
+++ b/rbutil/rbutilqt/base/utils.h
@@ -44,8 +44,8 @@ public:
static QString resolvePathCase(QString path);
static qulonglong filesystemFree(QString path);
static qulonglong filesystemTotal(QString path);
- static qulonglong filesystemClusterSize(QString path);
static qulonglong filesystemSize(QString path, enum Size type);
+ static QString filesystemType(QString path);
static QString findExecutable(QString name);
static QString checkEnvironment(bool permission);
static int compareVersionStrings(QString s1, QString s2);
diff --git a/rbutil/rbutilqt/base/zipinstaller.cpp b/rbutil/rbutilqt/base/zipinstaller.cpp
index caf1b52945..6c111a314d 100644
--- a/rbutil/rbutilqt/base/zipinstaller.cpp
+++ b/rbutil/rbutilqt/base/zipinstaller.cpp
@@ -139,7 +139,8 @@ void ZipInstaller::downloadDone(bool error)
// some room for operating (also includes calculation mistakes due to
// cluster sizes on the player).
if((qint64)Utils::filesystemFree(m_mountpoint)
- < (zip.totalUncompressedSize(Utils::filesystemClusterSize(m_mountpoint))
+ < (zip.totalUncompressedSize(
+ Utils::filesystemSize(m_mountpoint, Utils::FilesystemClusterSize))
+ 1000000)) {
emit logItem(tr("Not enough disk space! Aborting."), LOGERROR);
emit logProgress(1, 1);
diff --git a/rbutil/rbutilqt/sysinfo.cpp b/rbutil/rbutilqt/sysinfo.cpp
index 75ade2438f..9160ce9d9a 100644
--- a/rbutil/rbutilqt/sysinfo.cpp
+++ b/rbutil/rbutilqt/sysinfo.cpp
@@ -65,14 +65,14 @@ QString Sysinfo::getInfo(Sysinfo::InfoType type)
info += "<table>";
info += "<tr><td>" + tr("Mountpoint") + "</td><td>" + tr("Label")
+ "</td><td>" + tr("Free") + "</td><td>" + tr("Total") + "</td><td>"
- + tr("Cluster Size") + "</td></tr>";
+ + tr("Type") + "</td><td></tr>";
for(int i = 0; i < drives.size(); i++) {
info += tr("<tr><td>%1</td><td>%4</td><td>%2 GiB</td><td>%3 GiB</td><td>%5</td></tr>")
.arg(QDir::toNativeSeparators(drives.at(i)))
.arg((double)Utils::filesystemFree(drives.at(i)) / (1<<30), 0, 'f', 2)
.arg((double)Utils::filesystemTotal(drives.at(i)) / (1<<30), 0, 'f', 2)
.arg(Utils::filesystemName(drives.at(i)))
- .arg(Utils::filesystemClusterSize(drives.at(i)));
+ .arg(Utils::filesystemType(drives.at(i)));
}
info += "</table>";
info += "<hr/>";