summaryrefslogtreecommitdiffstats
path: root/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp')
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp106
1 files changed, 52 insertions, 54 deletions
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp
index 7c722a73d..253c32f5b 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp
@@ -22,105 +22,103 @@
#include "kdsysinfo.h"
-#include <QDir>
-#include <QDebug>
-
-#include <algorithm>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
using namespace KDUpdater;
-QDebug operator<<(QDebug dbg, VolumeInfo volume)
+struct PathLongerThan
{
- return dbg << "KDUpdater::Volume(" << volume.path() << ")";
-}
-
-//QPair<quint64, quint64> volumeSpace(const QString &volume);
-
-//QString volumeName(const QString &volume);
+ bool operator()(const VolumeInfo &lhs, const VolumeInfo &rhs) const
+ {
+ return lhs.mountPath().length() > rhs.mountPath().length();
+ }
+};
VolumeInfo::VolumeInfo()
+ : m_size(0)
+ , m_availableSize(0)
{
- m_size = 0;
- m_availableSpace = 0;
}
-void VolumeInfo::setPath(const QString &path)
+VolumeInfo VolumeInfo::fromPath(const QString &path)
{
- m_path = path;
+ QDir targetPath(path);
+ QList<VolumeInfo> volumes = mountedVolumes();
+ // sort by length to get the longest mount point (not just "/") first
+ qSort(volumes.begin(), volumes.end(), PathLongerThan());
+ foreach (const VolumeInfo &volume, volumes) {
+ QDir volumePath(volume.mountPath());
+ if (targetPath == volumePath)
+ return volume;
+#ifdef Q_OS_WIN
+ if (QDir::toNativeSeparators(path).toLower().startsWith(volume.mountPath().toLower()))
+#else
+ if (targetPath.canonicalPath().startsWith(volume.mountPath()))
+#endif
+ return volume;
+ }
+ return VolumeInfo();
}
-bool VolumeInfo::operator==(const VolumeInfo &other) const
+QString VolumeInfo::mountPath() const
{
- return m_name == other.m_name && m_path == other.m_path;
+ return m_mountPath;
}
-void VolumeInfo::setName(const QString &name)
+void VolumeInfo::setMountPath(const QString &path)
{
- m_name = name;
+ m_mountPath = path;
}
-QString VolumeInfo::name() const
+QString VolumeInfo::fileSystemType() const
{
- return m_name;
+ return m_fileSystemType;
}
-QString VolumeInfo::path() const
+void VolumeInfo::setFileSystemType(const QString &type)
{
- return m_path;
+ m_fileSystemType = type;
}
-quint64 VolumeInfo::size() const
+QString VolumeInfo::volumeDescriptor() const
{
- return m_size;
+ return m_volumeDescriptor;
}
-void VolumeInfo::setSize(const quint64 &size)
+void VolumeInfo::setVolumeDescriptor(const QString &descriptor)
{
- m_size = size;
+ m_volumeDescriptor = descriptor;
}
-QString VolumeInfo::fileSystemType() const
+quint64 VolumeInfo::size() const
{
- return m_fileSystemType;
+ return m_size;
}
-void VolumeInfo::setFileSystemType(const QString &type)
+void VolumeInfo::setSize(const quint64 &size)
{
- m_fileSystemType = type;
+ m_size = size;
}
-quint64 VolumeInfo::availableSpace() const
+quint64 VolumeInfo::availableSize() const
{
- return m_availableSpace;
+ return m_availableSize;
}
-void VolumeInfo::setAvailableSpace(const quint64 &available)
+void VolumeInfo::setAvailableSize(const quint64 &available)
{
- m_availableSpace = available;
+ m_availableSize = available;
}
-struct PathLongerThan
+bool VolumeInfo::operator==(const VolumeInfo &other) const
{
- bool operator()(const VolumeInfo &lhs, const VolumeInfo &rhs) const
- {
- return lhs.path().length() > rhs.path().length();
- }
-};
+ return m_volumeDescriptor == other.m_volumeDescriptor;
+}
-VolumeInfo VolumeInfo::fromPath(const QString &path)
+QDebug operator<<(QDebug dbg, VolumeInfo volume)
{
- QList<VolumeInfo> volumes = mountedVolumes();
- // sort by length to get the longest mount point (not just "/") first
- std::sort(volumes.begin(), volumes.end(), PathLongerThan());
- for (QList< VolumeInfo >::const_iterator it = volumes.constBegin(); it != volumes.constEnd(); ++it) {
-#ifdef Q_WS_WIN
- if (QDir::toNativeSeparators(path).toLower().startsWith(it->path().toLower()))
-#else
- if (QDir(path).canonicalPath().startsWith(it->path()))
-#endif
- return *it;
- }
- return VolumeInfo();
+ return dbg << "KDUpdater::Volume(" << volume.mountPath() << ")";
}
QDebug operator<<(QDebug dbg, ProcessInfo process)