diff options
author | Andy Shaw <andy.shaw@digia.com> | 2012-04-17 18:30:54 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-16 20:13:40 (GMT) |
commit | fd2eb070128ab6ef6b5c9343a0921f6b5a0bc041 (patch) | |
tree | 8dab8ec2f019cc143d6e123affd044018dfef029 /src/corelib/io | |
parent | fcfd40544f5730f8902544aac5ca5fafec52e5c2 (diff) | |
download | Qt-fd2eb070128ab6ef6b5c9343a0921f6b5a0bc041.zip Qt-fd2eb070128ab6ef6b5c9343a0921f6b5a0bc041.tar.gz Qt-fd2eb070128ab6ef6b5c9343a0921f6b5a0bc041.tar.bz2 |
Fix cases where functions are called with a drive and no slash
When a file is specified on a path that includes a drive letter
followed by a colon but no slash then it didn't always account
for the fact that this refers to the current path on that drive.
This fixes the problems in completeBaseName(), baseName() and
path(). Tests are also added for these three cases and some
others too.
Task-number: QTBUG-25353
Change-Id: I47a197c6af066f532442ad269be57597ec61303a
Reviewed-by: Irfan Omair <irfan.omair@gmail.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
(cherry picked from commit cfb44c6528b2518274bf157388832d1d610ce0e4)
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfilesystementry.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 11b73dd..3ee3a87 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -189,7 +189,7 @@ QString QFileSystemEntry::path() const if (m_lastSeparator == -1) { #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) if (m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) - return m_filePath.left(2); + return QFSFileEngine::currentPath(m_filePath.left(2)); #endif return QString(QLatin1Char('.')); } @@ -205,32 +205,32 @@ QString QFileSystemEntry::path() const QString QFileSystemEntry::baseName() const { findFileNameSeparators(); -#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) - if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) - return m_filePath.mid(2); -#endif int length = -1; if (m_firstDotInFileName >= 0) { length = m_firstDotInFileName; if (m_lastSeparator != -1) // avoid off by one length--; } +#if defined(Q_OS_WIN) + if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) + return m_filePath.mid(2, length - 2); +#endif return m_filePath.mid(m_lastSeparator + 1, length); } QString QFileSystemEntry::completeBaseName() const { findFileNameSeparators(); -#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) - if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) - return m_filePath.mid(2); -#endif int length = -1; if (m_firstDotInFileName >= 0) { length = m_firstDotInFileName + m_lastDotInFileName; if (m_lastSeparator != -1) // avoid off by one length--; } +#if defined(Q_OS_WIN) + if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) + return m_filePath.mid(2, length - 2); +#endif return m_filePath.mid(m_lastSeparator + 1, length); } |