summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2013-12-04 14:33:25 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-22 00:04:16 +0100
commitb5241296f8600ea3ba962c45ed8038abec5343f1 (patch)
tree5fbfff292fee6f0d4d5138b0dafaadfd214f31ec
parentdebe31e047060d790fb32c06e514d9df476df8bf (diff)
downloadqtbase-b5241296f8600ea3ba962c45ed8038abec5343f1.tar.gz
qtbase-b5241296f8600ea3ba962c45ed8038abec5343f1.tar.bz2
qtbase-b5241296f8600ea3ba962c45ed8038abec5343f1.zip
QDir: Do not assume that root ends with a slash
Root can also be "//server" Task-number: QTBUG-35402 Change-Id: I25250b7dcb10cba7b676a0c88b64a402494d7481 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/io/qdir.cpp9
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp4
2 files changed, 9 insertions, 4 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 015f4cfe14..b704126efa 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -716,11 +716,12 @@ QString QDir::absoluteFilePath(const QString &fileName) const
return fileName;
d->resolveAbsoluteEntry();
+ const QString absoluteDirPath = d->absoluteDirEntry.filePath();
if (fileName.isEmpty())
- return d->absoluteDirEntry.filePath();
- if (!d->absoluteDirEntry.isRoot())
- return d->absoluteDirEntry.filePath() % QLatin1Char('/') % fileName;
- return d->absoluteDirEntry.filePath() % fileName;
+ return absoluteDirPath;
+ if (!absoluteDirPath.endsWith(QLatin1Char('/')))
+ return absoluteDirPath % QLatin1Char('/') % fileName;
+ return absoluteDirPath % fileName;
}
/*!
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index 96be5065d6..2bac6f5834 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -1098,6 +1098,10 @@ void tst_QDir::absoluteFilePath_data()
QTest::newRow("2") << "/" << "passwd" << "/passwd";
QTest::newRow("3") << "relative" << "path" << QDir::currentPath() + "/relative/path";
QTest::newRow("4") << "" << "" << QDir::currentPath();
+#ifdef Q_OS_WIN
+ QTest::newRow("5") << "//machine" << "share" << "//machine/share";
+#endif
+
QTest::newRow("resource") << ":/prefix" << "foo.bar" << ":/prefix/foo.bar";
}