summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2010-09-08 13:02:19 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2010-09-08 13:02:19 (GMT)
commit0b662bd90347d152bf7371f1554e7bd2175704d8 (patch)
treea934784f30931f4a97f8ee0e215e5b50ad195af8 /src
parentbbbe13b676d297f0f5bfb754cdfe5ff1848c67b7 (diff)
downloadQt-0b662bd90347d152bf7371f1554e7bd2175704d8.zip
Qt-0b662bd90347d152bf7371f1554e7bd2175704d8.tar.gz
Qt-0b662bd90347d152bf7371f1554e7bd2175704d8.tar.bz2
Implement QFileSystemEngine::absoluteName for symbian OS
Updated this function so that it passes the QFileInfo autotests. Now deals with raw drives "x:" Drive relative paths "x:foo.txt" Absolute paths missing a drive letter "/sys" Dirty absolute paths "c:/bar/../foo" Reviewed-By: joao
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfilesystemengine_symbian.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp
index 45c3c10..3638196 100644
--- a/src/corelib/io/qfilesystemengine_symbian.cpp
+++ b/src/corelib/io/qfilesystemengine_symbian.cpp
@@ -80,23 +80,40 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry)
//static
QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
{
- if (entry.isAbsolute())
+ QString orig = entry.filePath();
+ const bool needsDrive = (!orig.isEmpty() && orig.at(0).unicode() == '/');
+ const bool isDriveLetter = (orig.size() == 2 && orig.at(1).unicode() == ':');
+ const bool isDriveRelative = (orig.size() > 2 && orig.at(1).unicode() == ':' && orig.at(2).unicode() != '/');
+ const bool isDirty = (orig.contains(QLatin1String("/../")) || orig.contains(QLatin1String("/./")) ||
+ orig.endsWith(QLatin1String("/..")) || orig.endsWith(QLatin1String("/.")));
+ const bool isAbsolute = entry.isAbsolute();
+ if (isAbsolute &&
+ !(needsDrive || isDriveLetter || isDriveRelative || isDirty))
return entry;
- QString orig = entry.filePath();
QString result;
- if (orig.isEmpty() || !orig.startsWith('/')) {
+ if (needsDrive || isDriveLetter || isDriveRelative || !isAbsolute || orig.isEmpty()) {
QFileSystemEntry cur(QFSFileEngine::currentPath());
- result = cur.filePath();
+ if(needsDrive)
+ result = cur.filePath().left(2);
+ else if(isDriveRelative && cur.filePath().at(0) != orig.at(0))
+ result = orig.left(2); // for BC, see tst_QFileInfo::absolutePath(<not current drive>:my.dll)
+ else
+ result = cur.filePath();
+ if(isDriveLetter) {
+ result[0] = orig.at(0); //copy drive letter
+ orig.clear();
+ }
+ if(isDriveRelative) {
+ orig = orig.mid(2); //discard the drive specifier from orig
+ }
}
- if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) {
+ if (!orig.isEmpty() && !(orig.length() == 1 && orig.at(0).unicode() == '.')) {
if (!result.isEmpty() && !result.endsWith('/'))
result.append('/');
result.append(orig);
}
- if (result.length() == 1 && result[0] == '/')
- return QFileSystemEntry(result);
const bool isDir = result.endsWith('/');
result = QDir::cleanPath(result);