summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qdir.cpp
diff options
context:
space:
mode:
authorSami Lempinen <sami.lempinen@nokia.com>2011-08-23 11:33:16 (GMT)
committerSami Lempinen <sami.lempinen@nokia.com>2011-08-23 11:33:16 (GMT)
commita28832bb61e7e60ac0fb856daf27b78ff1728520 (patch)
treed8ecd2387568814a68bf8b8713f3abed9ff9f275 /src/corelib/io/qdir.cpp
parent59f33898919391d3aa4baa6849556965ae7d08ce (diff)
parent2f5855e8d891a7e93bdb721243f1c0b10fcb5ad9 (diff)
downloadQt-a28832bb61e7e60ac0fb856daf27b78ff1728520.zip
Qt-a28832bb61e7e60ac0fb856daf27b78ff1728520.tar.gz
Qt-a28832bb61e7e60ac0fb856daf27b78ff1728520.tar.bz2
Merge remote-tracking branch 'qt/4.8'
Diffstat (limited to 'src/corelib/io/qdir.cpp')
-rw-r--r--src/corelib/io/qdir.cpp38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index b31cf69..f9196e0 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -802,14 +802,23 @@ QString QDir::convertSeparators(const QString &pathName)
*/
QString QDir::toNativeSeparators(const QString &pathName)
{
- QString n(pathName);
#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN)
- for (int i = 0; i < (int)n.length(); ++i) {
- if (n[i] == QLatin1Char('/'))
- n[i] = QLatin1Char('\\');
+ int i = pathName.indexOf(QLatin1Char('/'));
+ if (i != -1) {
+ QString n(pathName);
+
+ QChar * const data = n.data();
+ data[i++] = QLatin1Char('\\');
+
+ for (; i < n.length(); ++i) {
+ if (data[i] == QLatin1Char('/'))
+ data[i] = QLatin1Char('\\');
+ }
+
+ return n;
}
#endif
- return n;
+ return pathName;
}
/*!
@@ -826,14 +835,23 @@ QString QDir::toNativeSeparators(const QString &pathName)
*/
QString QDir::fromNativeSeparators(const QString &pathName)
{
- QString n(pathName);
#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN)
- for (int i = 0; i < (int)n.length(); ++i) {
- if (n[i] == QLatin1Char('\\'))
- n[i] = QLatin1Char('/');
+ int i = pathName.indexOf(QLatin1Char('\\'));
+ if (i != -1) {
+ QString n(pathName);
+
+ QChar * const data = n.data();
+ data[i++] = QLatin1Char('/');
+
+ for (; i < n.length(); ++i) {
+ if (data[i] == QLatin1Char('\\'))
+ data[i] = QLatin1Char('/');
+ }
+
+ return n;
}
#endif
- return n;
+ return pathName;
}
/*!