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>
This commit is contained in:
Oswald Buddenhagen 2018-03-21 17:51:54 +01:00
parent 04b93bfb21
commit 1d537071de

View File

@ -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());
}
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;