summaryrefslogtreecommitdiffstats
path: root/installerbuilder/common/binaryformat.cpp
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2011-05-12 12:04:55 +0200
committerkh1 <qt-info@nokia.com>2011-05-12 12:04:55 +0200
commitb50df6b7fcb0d1f69815fdd86a95e60691af691e (patch)
tree07494aed05dbb62f2e94b7c8daeefc401194c378 /installerbuilder/common/binaryformat.cpp
parent96db5ea975225350ef307b753fafd8f4a673074d (diff)
Implement read/ write to separate operation file.
Diffstat (limited to 'installerbuilder/common/binaryformat.cpp')
-rw-r--r--installerbuilder/common/binaryformat.cpp56
1 files changed, 35 insertions, 21 deletions
diff --git a/installerbuilder/common/binaryformat.cpp b/installerbuilder/common/binaryformat.cpp
index d469a5595..a35b1ffc0 100644
--- a/installerbuilder/common/binaryformat.cpp
+++ b/installerbuilder/common/binaryformat.cpp
@@ -853,7 +853,7 @@ BinaryContent BinaryContent::readFromBinary(const QString &path)
{
BinaryContent c(path);
- QFile* const file = c.file.data();
+ QFile *file = c.file.data();
if (!file->open(QIODevice::ReadOnly))
throw Error(QObject::tr("Could not open binary %1: %2").arg(path, file->errorString()));
@@ -890,27 +890,41 @@ BinaryContent BinaryContent::readFromBinary(const QString &path)
metadataResourceLength));
}
- if (!file->seek(operationsStart))
- throw Error(QObject::tr("Could not seek to operation list"));
-
- QStack<KDUpdater::UpdateOperation*> performedOperations;
- const qint64 operationsCount = retrieveInt64(file);
- verbose() << "operationsCount=" << operationsCount << std::endl;
-
- for (int i = operationsCount; --i >= 0;) {
- const QString name = retrieveString(file);
- const QString xml = retrieveString(file);
- KDUpdater::UpdateOperation* const op = KDUpdater::UpdateOperationFactory::instance().create(name);
- QString debugXmlString(xml);
- debugXmlString.truncate(1000);
- verbose() << "Operation name=" << name << " xml=\n" << debugXmlString << std::endl;
- Q_ASSERT_X(op, "BinaryContent::readFromBinary", QString::fromLatin1("Invalid operation name='%1'")
- .arg(name).toLatin1());
- if (! op->fromXml(xml))
- qWarning() << "Failed to load XML for operation=" << name;
- performedOperations.push(op);
+ if (c.m_magicmaker != MagicInstallerMarker) {
+ QString binaryPath = path;
+ QFileInfo fi(binaryPath + QLatin1String("/../../.."));
+ if (QFileInfo(fi.absoluteFilePath()).isBundle())
+ binaryPath = fi.absoluteFilePath();
+ fi.setFile(binaryPath);
+
+ QFile *tmp = file;
+ QFile operations(fi.absolutePath() + QLatin1Char('/') + fi.baseName() + QLatin1String(".dat"));
+ if (operations.exists() && operations.open(QIODevice::ReadOnly)) {
+ if (findMagicCookie(&operations) >= 0) {
+ tmp = &operations;
+ operationsStart = 0;
+ }
+ }
+
+ if (!tmp->seek(operationsStart))
+ throw Error(QObject::tr("Could not seek to operation list"));
+
+ const qint64 operationsCount = retrieveInt64(tmp);
+ verbose() << "operationsCount=" << operationsCount << std::endl;
+
+ for (int i = 0; i < operationsCount; ++i) {
+ const QString name = retrieveString(tmp);
+ KDUpdater::UpdateOperation *op = KDUpdater::UpdateOperationFactory::instance().create(name);
+ Q_ASSERT_X(op, __FUNCTION__, QString::fromLatin1("Invalid operation name: %1").arg(name)
+ .toLatin1());
+
+ const QString xml = retrieveString(tmp);
+ if (!op->fromXml(xml))
+ qWarning() << "Failed to load XML for operation:" << name;
+ verbose() << "Operation name: " << name << "\nOperation xml:\n" << xml.leftRef(1000) << std::endl;
+ c.m_performedOperations.push(op);
+ }
}
- c.m_performedOperations = performedOperations;
// seek to the position of the component index
if (!file->seek(endOfData - indexSize - resourceSectionSize - 2 * sizeof(qint64)))