summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2012-04-17 20:30:54 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-16 04:24:29 +0200
commitcfb44c6528b2518274bf157388832d1d610ce0e4 (patch)
tree146214ecd8e7d4ae595e208dba192e2b8ecd8809 /src/corelib/io
parentfb6d83cca59930345231161c1d6bfdf79fe25807 (diff)
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>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfilesystementry.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp
index 46881a1e5c..032a5bddf3 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)
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)
- 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)
- 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);
}