summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2011-08-11 15:49:37 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-06 11:24:20 +0200
commitd3ef64261484ef1e750671263429810918ca6954 (patch)
tree4768ba85fd65984489026329af9f2012e1ba340d /src
parentcdef65351917efd6de36a7c85b4bce2aaa249665 (diff)
Fix QDir::operator==(const QDir &) const
We can't rely on absolute paths when comparing directories for equality as these don't take into account symbolic links and may also bypass ../ and ./ simplification. Instead, canonical paths must be computed and can then be compared according to the case sensitivity rules for the platform or file engine, as is done in QFileInfo. Task-number: QTBUG-20495 Reviewed-by: Prasanth Ullattil (cherry-picked from dcee6e1371d899eb79717b8e3f3eec08b765db82) Change-Id: Ib5f2a6ee11311c55782ea5dd0e9c3b45f9231686 Reviewed-on: http://codereview.qt-project.org/5812 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qdir.cpp6
-rw-r--r--src/corelib/io/qfileinfo.cpp1
2 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 9faa9f17b3..0c7050095d 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1599,9 +1599,9 @@ bool QDir::operator==(const QDir &dir) const
if (d->filters == other->filters
&& d->sort == other->sort
&& d->nameFilters == other->nameFilters) {
- d->resolveAbsoluteEntry();
- other->resolveAbsoluteEntry();
- return d->absoluteDirEntry.filePath().compare(other->absoluteDirEntry.filePath(), sensitive) == 0;
+
+ // Fallback to expensive canonical path computation
+ return canonicalPath().compare(dir.canonicalPath(), sensitive) == 0;
}
return false;
}
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index c83c39195a..b560a81ac5 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -418,6 +418,7 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const
if (fileinfo.size() != size()) //if the size isn't the same...
return false;
+ // Fallback to expensive canonical path computation
return canonicalFilePath().compare(fileinfo.canonicalFilePath(), sensitive) == 0;
}