rcc: don't drop entries with missing files in -list mode
the files may not exist _yet_. this change allows dynamically generating the resource contents. the ignoreErrors parameter is renamed to listMode and made less aggressive, to better reflect the actual usage. Change-Id: I2f6a75a23f1ef903f0d957f9a09f4df0ce2a2b35 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
parent
4d15f393a7
commit
97d7a00989
@ -377,7 +377,7 @@ enum RCCXmlTag {
|
|||||||
Q_DECLARE_TYPEINFO(RCCXmlTag, Q_PRIMITIVE_TYPE);
|
Q_DECLARE_TYPEINFO(RCCXmlTag, Q_PRIMITIVE_TYPE);
|
||||||
|
|
||||||
bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
|
bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
|
||||||
const QString &fname, QString currentPath, bool ignoreErrors)
|
const QString &fname, QString currentPath, bool listMode)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_errorDevice);
|
Q_ASSERT(m_errorDevice);
|
||||||
const QChar slash = QLatin1Char('/');
|
const QChar slash = QLatin1Char('/');
|
||||||
@ -527,7 +527,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
|
|||||||
m_failedResources.push_back(child.fileName());
|
m_failedResources.push_back(child.fileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (file.isFile()) {
|
} else if (listMode || file.isFile()) {
|
||||||
const bool arc =
|
const bool arc =
|
||||||
addFile(alias,
|
addFile(alias,
|
||||||
RCCFileInfo(alias.section(slash, -1),
|
RCCFileInfo(alias.section(slash, -1),
|
||||||
@ -551,8 +551,6 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
|
|||||||
const QString msg = QString::fromLatin1("RCC: Error in '%1': Cannot find file '%2'\n")
|
const QString msg = QString::fromLatin1("RCC: Error in '%1': Cannot find file '%2'\n")
|
||||||
.arg(fname, fileName);
|
.arg(fname, fileName);
|
||||||
m_errorDevice->write(msg.toUtf8());
|
m_errorDevice->write(msg.toUtf8());
|
||||||
if (ignoreErrors)
|
|
||||||
continue;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -564,8 +562,6 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (reader.hasError()) {
|
if (reader.hasError()) {
|
||||||
if (ignoreErrors)
|
|
||||||
return true;
|
|
||||||
int errorLine = reader.lineNumber();
|
int errorLine = reader.lineNumber();
|
||||||
int errorColumn = reader.columnNumber();
|
int errorColumn = reader.columnNumber();
|
||||||
QString errorMessage = reader.errorString();
|
QString errorMessage = reader.errorString();
|
||||||
@ -577,7 +573,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
|
|||||||
if (m_root == 0) {
|
if (m_root == 0) {
|
||||||
const QString msg = QString::fromLatin1("RCC: Warning: No resources in '%1'.\n").arg(fname);
|
const QString msg = QString::fromLatin1("RCC: Warning: No resources in '%1'.\n").arg(fname);
|
||||||
m_errorDevice->write(msg.toUtf8());
|
m_errorDevice->write(msg.toUtf8());
|
||||||
if (!ignoreErrors && m_format == Binary) {
|
if (!listMode && m_format == Binary) {
|
||||||
// create dummy entry, otherwise loading with QResource will crash
|
// create dummy entry, otherwise loading with QResource will crash
|
||||||
m_root = new RCCFileInfo(QString(), QFileInfo(),
|
m_root = new RCCFileInfo(QString(), QFileInfo(),
|
||||||
QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory);
|
QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory);
|
||||||
@ -645,14 +641,14 @@ void RCCResourceLibrary::reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RCCResourceLibrary::readFiles(bool ignoreErrors, QIODevice &errorDevice)
|
bool RCCResourceLibrary::readFiles(bool listMode, QIODevice &errorDevice)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
m_errorDevice = &errorDevice;
|
m_errorDevice = &errorDevice;
|
||||||
//read in data
|
//read in data
|
||||||
if (m_verbose) {
|
if (m_verbose) {
|
||||||
const QString msg = QString::fromLatin1("Processing %1 files [%2]\n")
|
const QString msg = QString::fromLatin1("Processing %1 files [listMode=%2]\n")
|
||||||
.arg(m_fileNames.size()).arg(static_cast<int>(ignoreErrors));
|
.arg(m_fileNames.size()).arg(static_cast<int>(listMode));
|
||||||
m_errorDevice->write(msg.toUtf8());
|
m_errorDevice->write(msg.toUtf8());
|
||||||
}
|
}
|
||||||
for (int i = 0; i < m_fileNames.size(); ++i) {
|
for (int i = 0; i < m_fileNames.size(); ++i) {
|
||||||
@ -680,7 +676,7 @@ bool RCCResourceLibrary::readFiles(bool ignoreErrors, QIODevice &errorDevice)
|
|||||||
m_errorDevice->write(msg.toUtf8());
|
m_errorDevice->write(msg.toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!interpretResourceFile(&fileIn, fname, pwd, ignoreErrors))
|
if (!interpretResourceFile(&fileIn, fname, pwd, listMode))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
|
|
||||||
bool output(QIODevice &outDevice, QIODevice &tempDevice, QIODevice &errorDevice);
|
bool output(QIODevice &outDevice, QIODevice &tempDevice, QIODevice &errorDevice);
|
||||||
|
|
||||||
bool readFiles(bool ignoreErrors, QIODevice &errorDevice);
|
bool readFiles(bool listMode, QIODevice &errorDevice);
|
||||||
|
|
||||||
enum Format { Binary, C_Code, Pass1, Pass2 };
|
enum Format { Binary, C_Code, Pass1, Pass2 };
|
||||||
void setFormat(Format f) { m_format = f; }
|
void setFormat(Format f) { m_format = f; }
|
||||||
@ -109,7 +109,7 @@ private:
|
|||||||
void reset();
|
void reset();
|
||||||
bool addFile(const QString &alias, const RCCFileInfo &file);
|
bool addFile(const QString &alias, const RCCFileInfo &file);
|
||||||
bool interpretResourceFile(QIODevice *inputDevice, const QString &file,
|
bool interpretResourceFile(QIODevice *inputDevice, const QString &file,
|
||||||
QString currentPath = QString(), bool ignoreErrors = false);
|
QString currentPath = QString(), bool listMode = false);
|
||||||
bool writeHeader();
|
bool writeHeader();
|
||||||
bool writeDataBlobs();
|
bool writeDataBlobs();
|
||||||
bool writeDataNames();
|
bool writeDataNames();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user