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>bb10
parent
debe31e047
commit
b5241296f8
|
|
@ -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;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue