summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tools/rcc/main.cpp17
-rw-r--r--src/tools/rcc/rcc.cpp29
-rw-r--r--src/tools/rcc/rcc.h5
3 files changed, 38 insertions, 13 deletions
diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp
index 423b566896..d09d36c659 100644
--- a/src/tools/rcc/main.cpp
+++ b/src/tools/rcc/main.cpp
@@ -153,6 +153,9 @@ int runRcc(int argc, char *argv[])
QCommandLineOption projectOption(QStringLiteral("project"), QStringLiteral("Output a resource file containing all files from the current directory."));
parser.addOption(projectOption);
+ QCommandLineOption formatVersionOption(QStringLiteral("format-version"), QStringLiteral("The RCC format version to write"), QStringLiteral("number"));
+ parser.addOption(formatVersionOption);
+
parser.addPositionalArgument(QStringLiteral("inputs"), QStringLiteral("Input files (*.qrc)."));
@@ -160,7 +163,19 @@ int runRcc(int argc, char *argv[])
parser.process(app);
QString errorMsg;
- RCCResourceLibrary library;
+
+ quint8 formatVersion = 2;
+ if (parser.isSet(formatVersionOption)) {
+ bool ok = false;
+ formatVersion = parser.value(formatVersionOption).toUInt(&ok);
+ if (!ok) {
+ errorMsg = QLatin1String("Invalid format version specified");
+ } else if (formatVersion != 1 && formatVersion != 2) {
+ errorMsg = QLatin1String("Unsupported format version specified");
+ }
+ }
+
+ RCCResourceLibrary library(formatVersion);
if (parser.isSet(nameOption))
library.setInitName(parser.value(nameOption));
if (parser.isSet(rootOption)) {
diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp
index c8ac554cd4..26dacc48ec 100644
--- a/src/tools/rcc/rcc.cpp
+++ b/src/tools/rcc/rcc.cpp
@@ -204,11 +204,13 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib)
if (text || pass1)
lib.writeChar('\n');
- // last modified time stamp
- const QDateTime lastModified = m_fileInfo.lastModified();
- lib.writeNumber8(quint64(lastModified.isValid() ? lastModified.toMSecsSinceEpoch() : 0));
- if (text || pass1)
- lib.writeChar('\n');
+ if (lib.formatVersion() >= 2) {
+ // last modified time stamp
+ const QDateTime lastModified = m_fileInfo.lastModified();
+ lib.writeNumber8(quint64(lastModified.isValid() ? lastModified.toMSecsSinceEpoch() : 0));
+ if (text || pass1)
+ lib.writeChar('\n');
+ }
}
qint64 RCCFileInfo::writeDataBlob(RCCResourceLibrary &lib, qint64 offset,
@@ -341,7 +343,7 @@ RCCResourceLibrary::Strings::Strings() :
{
}
-RCCResourceLibrary::RCCResourceLibrary()
+RCCResourceLibrary::RCCResourceLibrary(quint8 formatVersion)
: m_root(0),
m_format(C_Code),
m_verbose(false),
@@ -352,7 +354,8 @@ RCCResourceLibrary::RCCResourceLibrary()
m_dataOffset(0),
m_useNameSpace(CONSTANT_USENAMESPACE),
m_errorDevice(0),
- m_outDevice(0)
+ m_outDevice(0),
+ m_formatVersion(formatVersion)
{
m_out.reserve(30 * 1000 * 1000);
}
@@ -1114,7 +1117,9 @@ bool RCCResourceLibrary::writeInitializer()
if (m_root) {
writeString(" ");
writeAddNamespaceFunction("qRegisterResourceData");
- writeString("\n (0x02, qt_resource_struct, "
+ writeString("\n (");
+ writeHex(m_formatVersion);
+ writeString(" qt_resource_struct, "
"qt_resource_name, qt_resource_data);\n");
}
writeString(" return 1;\n");
@@ -1135,7 +1140,9 @@ bool RCCResourceLibrary::writeInitializer()
if (m_root) {
writeString(" ");
writeAddNamespaceFunction("qUnregisterResourceData");
- writeString("\n (0x02, qt_resource_struct, "
+ writeString("\n (");
+ writeHex(m_formatVersion);
+ writeString(" qt_resource_struct, "
"qt_resource_name, qt_resource_data);\n");
}
writeString(" return 1;\n");
@@ -1152,10 +1159,10 @@ bool RCCResourceLibrary::writeInitializer()
} else if (m_format == Binary) {
int i = 4;
char *p = m_out.data();
- p[i++] = 0; // 0x02
p[i++] = 0;
p[i++] = 0;
- p[i++] = 2;
+ p[i++] = 0;
+ p[i++] = m_formatVersion;
p[i++] = (m_treeOffset >> 24) & 0xff;
p[i++] = (m_treeOffset >> 16) & 0xff;
diff --git a/src/tools/rcc/rcc.h b/src/tools/rcc/rcc.h
index 157cd4809f..19e04e401d 100644
--- a/src/tools/rcc/rcc.h
+++ b/src/tools/rcc/rcc.h
@@ -48,7 +48,7 @@ class RCCResourceLibrary
RCCResourceLibrary &operator=(const RCCResourceLibrary &);
public:
- RCCResourceLibrary();
+ RCCResourceLibrary(quint8 formatVersion);
~RCCResourceLibrary();
bool output(QIODevice &outDevice, QIODevice &tempDevice, QIODevice &errorDevice);
@@ -91,6 +91,8 @@ public:
QStringList failedResources() const { return m_failedResources; }
+ int formatVersion() const { return m_formatVersion; }
+
private:
struct Strings {
Strings();
@@ -141,6 +143,7 @@ private:
QIODevice *m_errorDevice;
QIODevice *m_outDevice;
QByteArray m_out;
+ quint8 m_formatVersion;
};
QT_END_NAMESPACE