aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-04-14 15:40:30 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2014-04-15 14:18:27 +0200
commitfdc392858716c390f1541430dad3bb6aefdf792e (patch)
treedaece0e70b9525ab45718ac9fd2019a215aecc71
parenta27e8552174475e95cb5ec42612c41e25bcd1364 (diff)
Work around braindead QFileInfo::exists() behavior for symbolic links.
Change-Id: If8002fc7be0cc6af954ebb28ccbcb7bee1031e1c Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r--src/lib/corelib/buildgraph/artifactcleaner.cpp2
-rw-r--r--src/lib/corelib/tools/fileinfo.cpp7
-rw-r--r--src/lib/corelib/tools/fileinfo.h3
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp15
4 files changed, 20 insertions, 7 deletions
diff --git a/src/lib/corelib/buildgraph/artifactcleaner.cpp b/src/lib/corelib/buildgraph/artifactcleaner.cpp
index 0e41deee7..6995af22b 100644
--- a/src/lib/corelib/buildgraph/artifactcleaner.cpp
+++ b/src/lib/corelib/buildgraph/artifactcleaner.cpp
@@ -71,7 +71,7 @@ static void invalidateArtifactTimestamp(Artifact *artifact)
static void removeArtifactFromDisk(Artifact *artifact, bool dryRun, const Logger &logger)
{
QFileInfo fileInfo(artifact->filePath());
- if (!fileInfo.exists()) {
+ if (!FileInfo::fileExists(fileInfo)) {
if (!dryRun)
invalidateArtifactTimestamp(artifact);
return;
diff --git a/src/lib/corelib/tools/fileinfo.cpp b/src/lib/corelib/tools/fileinfo.cpp
index ccde88f13..2db0a142b 100644
--- a/src/lib/corelib/tools/fileinfo.cpp
+++ b/src/lib/corelib/tools/fileinfo.cpp
@@ -225,6 +225,11 @@ bool FileInfo::isFileCaseCorrect(const QString &filePath)
#endif
}
+bool FileInfo::fileExists(const QFileInfo &fi)
+{
+ return fi.isSymLink() || fi.exists();
+}
+
#if defined(Q_OS_WIN)
#define z(x) reinterpret_cast<WIN32_FILE_ATTRIBUTE_DATA*>(const_cast<FileInfo::InternalStatType*>(&x))
@@ -315,7 +320,7 @@ bool FileInfo::isDir() const
// adapted from qtc/plugins/vcsbase/cleandialog.cpp
bool removeFileRecursion(const QFileInfo &f, QString *errorMessage)
{
- if (!f.exists())
+ if (!FileInfo::fileExists(f))
return true;
if (f.isDir()) {
const QDir dir(f.absoluteFilePath());
diff --git a/src/lib/corelib/tools/fileinfo.h b/src/lib/corelib/tools/fileinfo.h
index b5731cedd..d20c6cf8c 100644
--- a/src/lib/corelib/tools/fileinfo.h
+++ b/src/lib/corelib/tools/fileinfo.h
@@ -68,6 +68,9 @@ public:
static bool globMatches(const QRegExp &pattern, const QString &subject);
static bool isFileCaseCorrect(const QString &filePath);
+ // Symlink-correct check.
+ static bool fileExists(const QFileInfo &fi);
+
private:
#if defined(Q_OS_WIN)
struct InternalStatType
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index d4ff742cb..50ec294f7 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -468,6 +468,11 @@ void TestBlackbox::resolve_project_dry_run()
QVERIFY2(!QFile::exists(buildGraphPath), qPrintable(buildGraphPath));
}
+static bool symlinkExists(const QString &linkFilePath)
+{
+ return QFileInfo(linkFilePath).isSymLink();
+}
+
void TestBlackbox::clean()
{
const QString appObjectFilePath = buildDir + "/.obj/app/main.cpp" + QTC_HOST_OBJECT_SUFFIX;
@@ -506,7 +511,7 @@ void TestBlackbox::clean()
QVERIFY(!QFile(depObjectFilePath).exists());
QVERIFY(QFile(depLibFilePath).exists());
foreach (const QString &symLink, symlinks)
- QVERIFY2(QFile(symLink).exists(), qPrintable(symLink));
+ QVERIFY2(symlinkExists(symLink), qPrintable(symLink));
// Remove all.
QCOMPARE(runQbs(), 0);
@@ -518,7 +523,7 @@ void TestBlackbox::clean()
QVERIFY(!QFile(depObjectFilePath).exists());
QVERIFY(!QFile(depLibFilePath).exists());
foreach (const QString &symLink, symlinks)
- QVERIFY2(!QFile(symLink).exists(), qPrintable(symLink));
+ QVERIFY2(!symlinkExists(symLink), qPrintable(symLink));
// Dry run.
QCOMPARE(runQbs(), 0);
@@ -531,7 +536,7 @@ void TestBlackbox::clean()
QVERIFY(QFile(depObjectFilePath).exists());
QVERIFY(QFile(depLibFilePath).exists());
foreach (const QString &symLink, symlinks)
- QVERIFY2(QFile(symLink).exists(), qPrintable(symLink));
+ QVERIFY2(symlinkExists(symLink), qPrintable(symLink));
// Product-wise, dependency only.
QCOMPARE(runQbs(), 0);
@@ -547,7 +552,7 @@ void TestBlackbox::clean()
QVERIFY(!QFile(depObjectFilePath).exists());
QVERIFY(!QFile(depLibFilePath).exists());
foreach (const QString &symLink, symlinks)
- QVERIFY2(!QFile(symLink).exists(), qPrintable(symLink));
+ QVERIFY2(!symlinkExists(symLink), qPrintable(symLink));
// Product-wise, dependent product only.
QCOMPARE(runQbs(), 0);
@@ -563,7 +568,7 @@ void TestBlackbox::clean()
QVERIFY(QFile(depObjectFilePath).exists());
QVERIFY(QFile(depLibFilePath).exists());
foreach (const QString &symLink, symlinks)
- QVERIFY2(QFile(symLink).exists(), qPrintable(symLink));
+ QVERIFY2(symlinkExists(symLink), qPrintable(symLink));
}
void TestBlackbox::exportSimple()