summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2009-09-08 11:45:09 (GMT)
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2009-09-08 11:45:09 (GMT)
commitbeea786c9d1362b1fb12fdff209b842e21ef9cf8 (patch)
tree4f5ea99b62d56e5baded972c71ebe2ff40518f43 /src/corelib/io
parent22e8dd8653281ebf79fc7fc0061b225c8daf2977 (diff)
downloadQt-beea786c9d1362b1fb12fdff209b842e21ef9cf8.zip
Qt-beea786c9d1362b1fb12fdff209b842e21ef9cf8.tar.gz
Qt-beea786c9d1362b1fb12fdff209b842e21ef9cf8.tar.bz2
Fixed resolving absolute paths in Symbian.
Fixed resolving absolute path using QFileInfo for paths that were relative but contained the drive letter (e.g. "c:my.dll"). Absolute paths should now be properly cleaned in Symbian, too. Task-number: 255326 Reviewed-by: Janne Anttila
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 50b4af7..80ccda3 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -865,15 +865,22 @@ QString QFSFileEngine::fileName(FileName file) const
QString ret;
if (!isRelativePathSymbian(d->filePath)) {
if (d->filePath.size() > 2 && d->filePath.at(1) == QLatin1Char(':')
- && d->filePath.at(2) != slashChar || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt
- d->filePath.startsWith(slashChar) // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt
- ) {
- ret = QString(QDir::currentPath().left(2) + QDir::fromNativeSeparators(d->filePath));
+ && d->filePath.at(2) != slashChar){
+ // It's a drive-relative path, so C:a.txt -> C:/currentpath/a.txt,
+ // or if it's different drive than current, Z:a.txt -> Z:/a.txt
+ QString currentPath = QDir::currentPath();
+ if (0 == currentPath.left(1).compare(d->filePath.left(1), Qt::CaseInsensitive))
+ ret = currentPath + slashChar + d->filePath.mid(2);
+ else
+ ret = d->filePath.left(2) + slashChar + d->filePath.mid(2);
+ } else if (d->filePath.startsWith(slashChar)) {
+ // It's a absolute path to the current drive, so /a.txt -> C:/a.txt
+ ret = QDir::currentPath().left(2) + d->filePath;
} else {
ret = d->filePath;
}
} else {
- ret = QDir::cleanPath(QDir::currentPath() + slashChar + d->filePath);
+ ret = QDir::currentPath() + slashChar + d->filePath;
}
// The path should be absolute at this point.
@@ -889,6 +896,12 @@ QString QFSFileEngine::fileName(FileName file) const
ret[0] = ret.at(0).toUpper();
}
+ // Clean up the path
+ bool isDir = ret.endsWith(slashChar);
+ ret = QDir::cleanPath(ret);
+ if (isDir)
+ ret += slashChar;
+
if (file == AbsolutePathName) {
int slash = ret.lastIndexOf(slashChar);
if (slash < 0)