diff options
author | kh1 <karsten.heimrich@digia.com> | 2014-08-27 10:51:40 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2014-08-29 12:40:05 +0200 |
commit | df2663a932ffc1e68fbde4b9c60efb93e36b519e (patch) | |
tree | 93277db0760329fcf544dae99398a49a9ca74756 /src/libs/installer/binarycontent.cpp | |
parent | cf60ba8b28282d9ab08e53850b5d65a4454966f3 (diff) |
Let the binary layout function find the cookie on its own.
Saves some ugly looking call convention, as we need to find
the cookie anyway, pass the cookie instead of the position.
Change-Id: I2227576a8ad251fac5312fc477f8381287b0d36d
Reviewed-by: Niels Weber <niels.weber@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/libs/installer/binarycontent.cpp')
-rw-r--r-- | src/libs/installer/binarycontent.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libs/installer/binarycontent.cpp b/src/libs/installer/binarycontent.cpp index 5e2c77ebe..6280134d9 100644 --- a/src/libs/installer/binarycontent.cpp +++ b/src/libs/installer/binarycontent.cpp @@ -313,19 +313,20 @@ BinaryContent BinaryContent::readFromBinary(const QString &path) c.d->m_binaryDataFile.reset(new QFile(fi.absolutePath() + QLatin1Char('/') + fi.baseName() + QLatin1String(".dat"))); QInstaller::openForRead(c.d->m_binaryDataFile.data()); - cookiePos = findMagicCookie(c.d->m_binaryDataFile.data(), BinaryContent::MagicCookieDat); - readBinaryData(c, c.d->m_binaryDataFile, readBinaryLayout(c.d->m_binaryDataFile.data(), - cookiePos)); + readBinaryData(c, c.d->m_binaryDataFile, binaryLayout(c.d->m_binaryDataFile.data(), + BinaryContent::MagicCookieDat)); } else { // We are an installer, all data is appended to our binary itself. - readBinaryData(c, c.d->m_appBinary, readBinaryLayout(c.d->m_appBinary.data(), cookiePos)); + readBinaryData(c, c.d->m_appBinary, binaryLayout(c.d->m_appBinary.data(), + BinaryContent::MagicCookie)); } return c; } /* static */ -BinaryLayout BinaryContent::readBinaryLayout(QFile *const file, qint64 cookiePos) +BinaryLayout BinaryContent::binaryLayout(QFile *file, quint64 magicCookie) { + const qint64 cookiePos = BinaryContent::findMagicCookie(file, magicCookie); const qint64 indexSize = 5 * sizeof(qint64); if (!file->seek(cookiePos - indexSize)) { throw Error(QCoreApplication::translate("BinaryContent", |