summaryrefslogtreecommitdiffstats
path: root/installerbuilder
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@nokia.com>2012-01-30 11:00:20 +0100
committerKarsten Heimrich <karsten.heimrich@nokia.com>2012-02-01 15:30:52 +0100
commit07009eaa803bbc61e83c1ae8d21027798657e004 (patch)
treee5304f7d0a4271175c43cbcbde14bcf3969a0f35 /installerbuilder
parent0292872fed2e1bb3d3a4bb9728b086336c49c6b0 (diff)
Solve the target path till we find the first existing dir.
Since canonicalPath might return an empty path if the target does not exist yet, we need to cd up on the path till we find the first existing one. Solves the problem that we would never return a valid volume, as empty paths can't be matched... Change-Id: Ia60bd68c43a5bac34ba612915aa5a3d572b64945 Reviewed-by: Alexander Lenhardt <alexander.lenhardt@nokia.com> Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
Diffstat (limited to 'installerbuilder')
-rw-r--r--installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp
index 253c32f5b..a0ace68c3 100644
--- a/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp
+++ b/installerbuilder/libinstaller/3rdparty/kdtools/kdsysinfo.cpp
@@ -43,17 +43,34 @@ VolumeInfo::VolumeInfo()
VolumeInfo VolumeInfo::fromPath(const QString &path)
{
- QDir targetPath(path);
+ QDir targetPath(QDir::cleanPath(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());
+ const QDir volumePath(volume.mountPath());
if (targetPath == volumePath)
return volume;
#ifdef Q_OS_WIN
if (QDir::toNativeSeparators(path).toLower().startsWith(volume.mountPath().toLower()))
#else
+ // we need to take some care here, as canonical path might return an empty string if the target
+ // does not exist yet
+ if (targetPath.exists()) {
+ // the target exist, we can solve the path and if it fits return
+ if (targetPath.canonicalPath().startsWith(volume.mountPath()))
+ return volume;
+ continue;
+ }
+
+ // the target directory does not exist yet, we need to cd up till we find the first existing dir
+ while (targetPath.absolutePath() != QDir::rootPath()) {
+ if (targetPath.exists())
+ break;
+ targetPath.cdUp();
+ }
+
if (targetPath.canonicalPath().startsWith(volume.mountPath()))
#endif
return volume;