rcc: Replace all occurrences of the marker in two-pass mode
The marker can occur legitimately twice e.g. on iOS with universal binaries. Change-Id: Ie334bcd104d45140ff969f44230e6de2212e8e25 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
This commit is contained in:
parent
ade8e0fc9b
commit
9b7bdd455f
@ -730,33 +730,37 @@ bool RCCResourceLibrary::output(QIODevice &outDevice, QIODevice &tempDevice, QIO
|
|||||||
{
|
{
|
||||||
m_errorDevice = &errorDevice;
|
m_errorDevice = &errorDevice;
|
||||||
|
|
||||||
const char pattern[] = { 'Q', 'R', 'C', '_', 'D', 'A', 'T', 'A' };
|
|
||||||
if (m_format == Pass2) {
|
if (m_format == Pass2) {
|
||||||
char c;
|
const char pattern[] = { 'Q', 'R', 'C', '_', 'D', 'A', 'T', 'A' };
|
||||||
for (int i = 0; i < 8; ) {
|
bool foundSignature = false;
|
||||||
if (!tempDevice.getChar(&c)) {
|
|
||||||
m_errorDevice->write("No data signature found\n");
|
while (true) {
|
||||||
return false;
|
char c;
|
||||||
}
|
for (int i = 0; i < 8; ) {
|
||||||
if (c == pattern[i]) {
|
if (!tempDevice.getChar(&c)) {
|
||||||
++i;
|
if (foundSignature)
|
||||||
} else {
|
return true;
|
||||||
for (int k = 0; k < i; ++k)
|
m_errorDevice->write("No data signature found\n");
|
||||||
outDevice.putChar(pattern[k]);
|
return false;
|
||||||
outDevice.putChar(c);
|
}
|
||||||
i = 0;
|
if (c == pattern[i]) {
|
||||||
|
++i;
|
||||||
|
} else {
|
||||||
|
for (int k = 0; k < i; ++k)
|
||||||
|
outDevice.putChar(pattern[k]);
|
||||||
|
outDevice.putChar(c);
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_outDevice = &outDevice;
|
||||||
|
quint64 start = outDevice.pos();
|
||||||
|
writeDataBlobs();
|
||||||
|
quint64 len = outDevice.pos() - start;
|
||||||
|
|
||||||
|
tempDevice.seek(tempDevice.pos() + len - 8);
|
||||||
|
foundSignature = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_outDevice = &outDevice;
|
|
||||||
quint64 start = outDevice.pos();
|
|
||||||
writeDataBlobs();
|
|
||||||
quint64 len = outDevice.pos() - start;
|
|
||||||
|
|
||||||
tempDevice.seek(tempDevice.pos() + len - 8);
|
|
||||||
outDevice.write(tempDevice.readAll());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//write out
|
//write out
|
||||||
|
Loading…
x
Reference in New Issue
Block a user