summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2018-03-21 17:51:54 +0100
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2018-03-29 18:16:50 +0000
commit1d537071dea5668df991b0ccb82f14a5880b62c9 (patch)
treebbafda515a3ae92982894253d2ef287d924e71e8
parent04b93bfb2127a88f35d2b251e900163f982e7cfe (diff)
rcc: prune dead wildcard matching code
clearly, rcc was meant to support wildcard patterns in <file> entries. however, since its inception, this code was broken: the exists() check was done first, so the decomposition into path and wildcard would never happen. as actually supporting wildcards woulds just complicate matters, simply remove that dead code. on the way, re-arrange the code in a way that is advantageous for subsequent changes, and insert a case that catches non-regular file nodes (this would have previously run into the wildcard code). Change-Id: Iac1a168b844ef5b176f6cc45d6a779fde0bec6f7 Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--src/tools/rcc/rcc.cpp61
1 files changed, 29 insertions, 32 deletions
diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp
index 92d3c5c171..4c7d095ca3 100644
--- a/src/tools/rcc/rcc.cpp
+++ b/src/tools/rcc/rcc.cpp
@@ -504,38 +504,8 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
if (QDir::isRelativePath(absFileName))
absFileName.prepend(currentPath);
QFileInfo file(absFileName);
- if (!file.exists()) {
- m_failedResources.push_back(absFileName);
- const QString msg = QString::fromLatin1("RCC: Error in '%1': Cannot find file '%2'\n")
- .arg(fname, fileName);
- m_errorDevice->write(msg.toUtf8());
- if (ignoreErrors)
- continue;
- else
- return false;
- } else if (file.isFile()) {
- const bool arc =
- addFile(alias,
- RCCFileInfo(alias.section(slash, -1),
- file,
- language,
- country,
- RCCFileInfo::NoFlags,
- compressLevel,
- compressThreshold)
- );
- if (!arc)
- m_failedResources.push_back(absFileName);
- } else {
- QDir dir;
- if (file.isDir()) {
- dir.setPath(file.filePath());
- } else {
- dir.setPath(file.path());
- dir.setNameFilters(QStringList(file.fileName()));
- if (alias.endsWith(file.fileName()))
- alias = alias.left(alias.length()-file.fileName().length());
- }
+ if (file.isDir()) {
+ QDir dir(file.filePath());
if (!alias.endsWith(slash))
alias += slash;
QDirIterator it(dir, QDirIterator::FollowSymlinks|QDirIterator::Subdirectories);
@@ -557,6 +527,33 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
m_failedResources.push_back(child.fileName());
}
}
+ } else if (file.isFile()) {
+ const bool arc =
+ addFile(alias,
+ RCCFileInfo(alias.section(slash, -1),
+ file,
+ language,
+ country,
+ RCCFileInfo::NoFlags,
+ compressLevel,
+ compressThreshold)
+ );
+ if (!arc)
+ m_failedResources.push_back(absFileName);
+ } else if (file.exists()) {
+ m_failedResources.push_back(absFileName);
+ const QString msg = QString::fromLatin1("RCC: Error in '%1': Entry '%2' is neither a file nor a directory\n")
+ .arg(fname, fileName);
+ m_errorDevice->write(msg.toUtf8());
+ return false;
+ } else {
+ m_failedResources.push_back(absFileName);
+ const QString msg = QString::fromLatin1("RCC: Error in '%1': Cannot find file '%2'\n")
+ .arg(fname, fileName);
+ m_errorDevice->write(msg.toUtf8());
+ if (ignoreErrors)
+ continue;
+ return false;
}
}
break;