Revert path() behavior to not expand a current path on a drive

In the original change - cfb44c6528 - when
querying for the path of a file that did not contain a slash after the
drive indicator it would get the current path and return that as the path
that the file resided on.

However this meant that it would take the current path at that time which
may not be the actual path that was expected. So it was decided that
it should revert back to the original behavior which was to just return
the drive letter followed by the colon which would thus indicate still
that it represented whatever the current path was on that drive.

Change-Id: Ic57ae9227882a66e9a4c4d6537d7f2cae829165a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
Andy Shaw 2014-02-21 15:21:24 +01:00 committed by The Qt Project
parent 4b2f35d04c
commit f07841bc7c
2 changed files with 2 additions and 2 deletions

View File

@ -195,7 +195,7 @@ QString QFileSystemEntry::path() const
if (m_lastSeparator == -1) {
#if defined(Q_OS_WIN)
if (m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':'))
return QFSFileEngine::currentPath(m_filePath.left(2));
return m_filePath.left(2);
#endif
return QString(QLatin1Char('.'));
}

View File

@ -713,7 +713,7 @@ void tst_QFileInfo::dir_data()
QTest::newRow("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << true << ":/tst_qfileinfo/resources";
#ifdef Q_OS_WIN
QTest::newRow("driveWithSlash") << "C:/file1.ext1.ext2" << true << "C:/";
QTest::newRow("driveWithoutSlash") << QDir::currentPath().left(2) + "file1.ext1.ext2" << false << QDir::currentPath();
QTest::newRow("driveWithoutSlash") << QDir::currentPath().left(2) + "file1.ext1.ext2" << false << QDir::currentPath().left(2);
#endif
}