summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/installer/binaryformat.cpp226
-rw-r--r--src/libs/installer/binaryformat.h69
-rw-r--r--src/libs/installer/createlocalrepositoryoperation.cpp7
-rw-r--r--src/libs/installer/fileio.cpp195
-rw-r--r--src/libs/installer/fileio.h85
-rw-r--r--src/libs/installer/fileutils.cpp70
-rw-r--r--src/libs/installer/fileutils.h11
-rw-r--r--src/libs/installer/installer.pro6
-rw-r--r--src/libs/installer/lib7z_facade.cpp47
-rw-r--r--src/libs/installer/lib7z_facade.h52
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp92
-rw-r--r--src/libs/installer/packagemanagercore_p.h4
-rw-r--r--src/libs/kdtools/kdsavefile.cpp2
-rw-r--r--src/libs/kdtools/kdsavefile.h2
-rw-r--r--src/sdk/installerbase_p.cpp6
-rw-r--r--tests/auto/installer/binaryformat/tst_binaryformat.cpp2
-rw-r--r--tests/auto/installer/task/tst_task.cpp2
-rw-r--r--tools/binarycreator/binarycreator.cpp39
-rw-r--r--tools/common/repositorygen.cpp15
19 files changed, 484 insertions, 448 deletions
diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp
index 58b46d64c..9e85ea61f 100644
--- a/src/libs/installer/binaryformat.cpp
+++ b/src/libs/installer/binaryformat.cpp
@@ -42,168 +42,20 @@
#include "binaryformat.h"
#include "errors.h"
+#include "fileio.h"
#include "fileutils.h"
#include "lib7z_facade.h"
#include "utils.h"
-#include <kdupdaterupdateoperationfactory.h>
+#include "kdupdaterupdateoperationfactory.h"
-#include <QDir>
-#include <QFileInfo>
+#include <QDebug>
#include <QResource>
#include <QTemporaryFile>
-#include <errno.h>
-#include <string.h>
-
using namespace QInstaller;
using namespace QInstallerCreator;
-static inline QByteArray &theBuffer(int size)
-{
- static QByteArray b;
- if (size > b.size())
- b.resize(size);
- return b;
-}
-
-void QInstaller::appendFileData(QIODevice *out, QIODevice *in)
-{
- Q_ASSERT(!in->isSequential());
- const qint64 size = in->size();
- blockingCopy(in, out, size);
-}
-
-
-void QInstaller::retrieveFileData(QIODevice *out, QIODevice *in)
-{
- qint64 size = QInstaller::retrieveInt64(in);
- appendData(in, out, size);
-}
-
-void QInstaller::appendInt64(QIODevice *out, qint64 n)
-{
- blockingWrite(out, reinterpret_cast<const char*>(&n), sizeof(n));
-}
-
-void QInstaller::appendInt64Range(QIODevice *out, const Range<qint64> &r)
-{
- appendInt64(out, r.start());
- appendInt64(out, r.length());
-}
-
-qint64 QInstaller::retrieveInt64(QIODevice *in)
-{
- qint64 n = 0;
- blockingRead(in, reinterpret_cast<char*>(&n), sizeof(n));
- return n;
-}
-
-Range<qint64> QInstaller::retrieveInt64Range(QIODevice *in)
-{
- const quint64 start = retrieveInt64(in);
- const quint64 length = retrieveInt64(in);
- return Range<qint64>::fromStartAndLength(start, length);
-}
-
-void QInstaller::appendData(QIODevice *out, QIODevice *in, qint64 size)
-{
- while (size > 0) {
- const qint64 nextSize = qMin(size, 16384LL);
- QByteArray &b = theBuffer(nextSize);
- blockingRead(in, b.data(), nextSize);
- blockingWrite(out, b.constData(), nextSize);
- size -= nextSize;
- }
-}
-
-void QInstaller::appendString(QIODevice *out, const QString &str)
-{
- appendByteArray(out, str.toUtf8());
-}
-
-void QInstaller::appendByteArray(QIODevice *out, const QByteArray &ba)
-{
- appendInt64(out, ba.size());
- blockingWrite(out, ba.constData(), ba.size());
-}
-
-void QInstaller::appendStringList(QIODevice *out, const QStringList &list)
-{
- appendInt64(out, list.size());
- foreach (const QString &s, list)
- appendString(out, s);
-}
-
-void QInstaller::appendDictionary(QIODevice *out, const QHash<QString,QString> &dict)
-{
- appendInt64(out, dict.size());
- foreach (const QString &key, dict.keys()) {
- appendString(out, key);
- appendString(out, dict.value(key));
- }
-}
-
-qint64 QInstaller::appendCompressedData(QIODevice *out, QIODevice *in, qint64 size)
-{
- QByteArray ba;
- ba.resize(size);
- blockingRead(in, ba.data(), size);
-
- QByteArray cba = qCompress(ba);
- blockingWrite(out, cba, cba.size());
- return cba.size();
-}
-
-QString QInstaller::retrieveString(QIODevice *in)
-{
- const QByteArray b = retrieveByteArray(in);
- return QString::fromUtf8(b);
-}
-
-QByteArray QInstaller::retrieveByteArray(QIODevice *in)
-{
- QByteArray ba;
- const qint64 n = retrieveInt64(in);
- ba.resize(n);
- blockingRead(in, ba.data(), n);
- return ba;
-}
-
-QStringList QInstaller::retrieveStringList(QIODevice *in)
-{
- QStringList list;
- for (qint64 i = retrieveInt64(in); --i >= 0;)
- list << retrieveString(in);
- return list;
-}
-
-QHash<QString,QString> QInstaller::retrieveDictionary(QIODevice *in)
-{
- QHash<QString,QString> dict;
- for (qint64 i = retrieveInt64(in); --i >= 0;) {
- QString key = retrieveString(in);
- dict.insert(key, retrieveString(in));
- }
- return dict;
-}
-
-QByteArray QInstaller::retrieveData(QIODevice *in, qint64 size)
-{
- QByteArray ba;
- ba.resize(size);
- blockingRead(in, ba.data(), size);
- return ba;
-}
-
-QByteArray QInstaller::retrieveCompressedData(QIODevice *in, qint64 size)
-{
- QByteArray ba;
- ba.resize(size);
- blockingRead(in, ba.data(), size);
- return qUncompress(ba);
-}
-
/*!
Search through 1MB, if smaller through the whole file. Note: QFile::map() does
not change QFile::pos(). Fallback to read the file content in case we can't map it.
@@ -227,7 +79,7 @@ qint64 QInstaller::findMagicCookie(QFile *in, quint64 magicCookie)
const int pos = in->pos();
try {
in->seek(fileSize - maxSearch);
- blockingRead(in, data.data(), maxSearch);
+ QInstaller::blockingRead(in, data.data(), maxSearch);
in->seek(pos);
} catch (const Error &error) {
in->seek(pos);
@@ -471,27 +323,27 @@ void Component::setBinarySegment(const Range<qint64> &r)
Component Component::readFromIndexEntry(const QSharedPointer<QFile> &in, qint64 offset)
{
Component c;
- c.m_name = retrieveByteArray(in.data());
- c.m_binarySegment = retrieveInt64Range(in.data()).moved(offset);
+ c.m_name = QInstaller::retrieveByteArray(in.data());
+ c.m_binarySegment = QInstaller::retrieveInt64Range(in.data()).moved(offset);
c.readData(in, offset);
return c;
}
-void Component::writeIndexEntry(QIODevice *out, qint64 positionOffset) const
+void Component::writeIndexEntry(QFileDevice *out, qint64 positionOffset) const
{
- appendByteArray(out, m_name);
+ QInstaller::appendByteArray(out, m_name);
m_binarySegment.moved(positionOffset);
- appendInt64(out, binarySegment().start());
- appendInt64(out, binarySegment().length());
+ QInstaller::appendInt64(out, binarySegment().start());
+ QInstaller::appendInt64(out, binarySegment().length());
}
-void Component::writeData(QIODevice *out, qint64 offset) const
+void Component::writeData(QFileDevice *out, qint64 offset) const
{
const qint64 dataBegin = out->pos() + offset;
- appendInt64(out, m_archives.count());
+ QInstaller::appendInt64(out, m_archives.count());
qint64 start = out->pos() + offset;
@@ -503,9 +355,9 @@ void Component::writeData(QIODevice *out, qint64 offset) const
QList<qint64> starts;
foreach (const QSharedPointer<Archive> &archive, m_archives) {
- appendByteArray(out, archive->name());
+ QInstaller::appendByteArray(out, archive->name());
starts.push_back(start);
- appendInt64Range(out, Range<qint64>::fromStartAndLength(start, archive->size()));
+ QInstaller::appendInt64Range(out, Range<qint64>::fromStartAndLength(start, archive->size()));
start += archive->size();
}
@@ -520,7 +372,7 @@ void Component::writeData(QIODevice *out, qint64 offset) const
Q_UNUSED(expectedStart);
Q_UNUSED(actualStart);
Q_ASSERT(expectedStart == actualStart);
- blockingCopy(archive.data(), out, archive->size());
+ QInstaller::blockingCopy(archive.data(), out, archive->size());
}
m_binarySegment = Range<qint64>::fromStartAndEnd(dataBegin, out->pos() + offset);
@@ -531,13 +383,13 @@ void Component::readData(const QSharedPointer<QFile> &in, qint64 offset)
const qint64 pos = in->pos();
in->seek(m_binarySegment.start());
- const qint64 count = retrieveInt64(in.data());
+ const qint64 count = QInstaller::retrieveInt64(in.data());
QVector<QByteArray> names;
QVector<Range<qint64> > ranges;
for (int i = 0; i < count; ++i) {
- names.push_back(retrieveByteArray(in.data()));
- ranges.push_back(retrieveInt64Range(in.data()).moved(offset));
+ names.push_back(QInstaller::retrieveByteArray(in.data()));
+ ranges.push_back(QInstaller::retrieveInt64Range(in.data()).moved(offset));
}
for (int i = 0; i < ranges.count(); ++i)
@@ -612,26 +464,26 @@ ComponentIndex::ComponentIndex()
ComponentIndex ComponentIndex::read(const QSharedPointer<QFile> &dev, qint64 offset)
{
ComponentIndex result;
- const qint64 size = retrieveInt64(dev.data());
+ const qint64 size = QInstaller::retrieveInt64(dev.data());
for (int i = 0; i < size; ++i)
result.insertComponent(Component::readFromIndexEntry(dev, offset));
- retrieveInt64(dev.data());
+ QInstaller::retrieveInt64(dev.data());
return result;
}
-void ComponentIndex::writeIndex(QIODevice *out, qint64 offset) const
+void ComponentIndex::writeIndex(QFileDevice *out, qint64 offset) const
{
// Q: why do we write the size twice?
// A: for us to be able to read it beginning from the end of the file as well
- appendInt64(out, componentCount());
+ QInstaller::appendInt64(out, componentCount());
foreach (const Component& i, components())
i.writeIndexEntry(out, offset);
- appendInt64(out, componentCount());
+ QInstaller::appendInt64(out, componentCount());
}
-void ComponentIndex::writeComponentData(QIODevice *out, qint64 offset) const
+void ComponentIndex::writeComponentData(QFileDevice *out, qint64 offset) const
{
- appendInt64(out, componentCount());
+ QInstaller::appendInt64(out, componentCount());
foreach (const Component &component, m_components)
component.writeData(out, offset);
@@ -677,7 +529,7 @@ static QByteArray addResourceFromBinary(QFile* file, const Range<qint64> &segmen
.arg(QString::number(segment.start()), QString::number(segment.length())));
}
- QByteArray ba = retrieveData(file, segment.length());
+ QByteArray ba = QInstaller::retrieveData(file, segment.length());
if (!QResource::registerResource((const uchar*)ba.constData(), QLatin1String(":/metadata")))
throw Error(QObject::tr("Could not register in-binary resource."));
return ba;
@@ -900,19 +752,19 @@ BinaryContent BinaryContent::readFromBinary(const QString &path)
}
/* static */
-BinaryLayout BinaryContent::readBinaryLayout(QIODevice *const file, qint64 cookiePos)
+BinaryLayout BinaryContent::readBinaryLayout(QFile *const file, qint64 cookiePos)
{
const qint64 indexSize = 5 * sizeof(qint64);
if (!file->seek(cookiePos - indexSize))
throw Error(QObject::tr("Could not seek to binary layout section."));
BinaryLayout layout;
- layout.operationsStart = retrieveInt64(file);
- layout.operationsEnd = retrieveInt64(file);
- layout.resourceCount = retrieveInt64(file);
- layout.dataBlockSize = retrieveInt64(file);
- layout.magicMarker = retrieveInt64(file);
- layout.magicCookie = retrieveInt64(file);
+ layout.operationsStart = QInstaller::retrieveInt64(file);
+ layout.operationsEnd = QInstaller::retrieveInt64(file);
+ layout.resourceCount = QInstaller::retrieveInt64(file);
+ layout.dataBlockSize = QInstaller::retrieveInt64(file);
+ layout.magicMarker = QInstaller::retrieveInt64(file);
+ layout.magicCookie = QInstaller::retrieveInt64(file);
layout.indexSize = indexSize + sizeof(qint64);
layout.endOfData = file->pos();
@@ -931,8 +783,8 @@ BinaryLayout BinaryContent::readBinaryLayout(QIODevice *const file, qint64 cooki
if (!file->seek(layout.endOfData - layout.indexSize - resourceOffsetAndLengtSize * (i + 1)))
throw Error(QObject::tr("Could not seek to metadata index."));
- const qint64 metadataResourceOffset = retrieveInt64(file);
- const qint64 metadataResourceLength = retrieveInt64(file);
+ const qint64 metadataResourceOffset = QInstaller::retrieveInt64(file);
+ const qint64 metadataResourceLength = QInstaller::retrieveInt64(file);
layout.metadataResourceSegments.append(Range<qint64>::fromStartAndLength(metadataResourceOffset
+ dataBlockStart, metadataResourceLength));
}
@@ -952,12 +804,12 @@ void BinaryContent::readBinaryData(BinaryContent &content, const QSharedPointer<
if (!file->seek(operationsStart))
throw Error(QObject::tr("Could not seek to operation list."));
- const qint64 operationsCount = retrieveInt64(file.data());
+ const qint64 operationsCount = QInstaller::retrieveInt64(file.data());
qDebug() << "Number of operations:" << operationsCount;
for (int i = 0; i < operationsCount; ++i) {
- const QString name = retrieveString(file.data());
- const QString data = retrieveString(file.data());
+ const QString name = QInstaller::retrieveString(file.data());
+ const QString data = QInstaller::retrieveString(file.data());
content.d->m_performedOperationsData.append(qMakePair(name, data));
}
@@ -967,7 +819,7 @@ void BinaryContent::readBinaryData(BinaryContent &content, const QSharedPointer<
if (!file->seek(layout.endOfData - layout.indexSize - resourceSectionSize - resourceOffsetAndLengtSize))
throw Error(QObject::tr("Could not seek to component index information."));
- const qint64 compIndexStart = retrieveInt64(file.data()) + dataBlockStart;
+ const qint64 compIndexStart = QInstaller::retrieveInt64(file.data()) + dataBlockStart;
if (!file->seek(compIndexStart))
throw Error(QObject::tr("Could not seek to component index."));
diff --git a/src/libs/installer/binaryformat.h b/src/libs/installer/binaryformat.h
index c3d8dbde9..4a7990c75 100644
--- a/src/libs/installer/binaryformat.h
+++ b/src/libs/installer/binaryformat.h
@@ -46,50 +46,15 @@
#include "range.h"
#include "qinstallerglobal.h"
-#include <QtCore/QCoreApplication>
-#include <QtCore/QFile>
-#include <QtCore/QHash>
-#include <QtCore/QStack>
-#include <QtCore/QVector>
-#include <QtCore/QSharedPointer>
-
-namespace QInstaller {
- static const qint64 MagicInstallerMarker = 0x12023233UL;
- static const qint64 MagicUninstallerMarker = 0x12023234UL;
-
- static const qint64 MagicUpdaterMarker = 0x12023235UL;
- static const qint64 MagicPackageManagerMarker = 0x12023236UL;
-
- // this cookie is put at the end of the file to determine whether we have data
- static const quint64 MagicCookie = 0xc2630a1c99d668f8LL;
- static const quint64 MagicCookieDat = 0xc2630a1c99d668f9LL;
-
- qint64 INSTALLER_EXPORT findMagicCookie(QFile *file, quint64 magicCookie = MagicCookie);
- void INSTALLER_EXPORT appendFileData(QIODevice *out, QIODevice *in);
- void INSTALLER_EXPORT appendInt64(QIODevice *out, qint64 n);
- void INSTALLER_EXPORT appendInt64Range(QIODevice *out, const Range<qint64> &r);
- void INSTALLER_EXPORT appendData(QIODevice *out, QIODevice *in, qint64 size);
- void INSTALLER_EXPORT appendByteArray(QIODevice *out, const QByteArray &ba);
- void INSTALLER_EXPORT appendString(QIODevice *out, const QString &str);
- void INSTALLER_EXPORT appendStringList(QIODevice *out, const QStringList &list);
- void INSTALLER_EXPORT appendDictionary(QIODevice *out, const QHash<QString,QString> &dict);
- qint64 INSTALLER_EXPORT appendCompressedData(QIODevice *out, QIODevice *in, qint64 size);
-
- void INSTALLER_EXPORT retrieveFileData(QIODevice *out, QIODevice *in);
- qint64 INSTALLER_EXPORT retrieveInt64(QIODevice *in);
- Range<qint64> INSTALLER_EXPORT retrieveInt64Range(QIODevice *in);
- QByteArray INSTALLER_EXPORT retrieveByteArray(QIODevice *in);
- QString INSTALLER_EXPORT retrieveString(QIODevice *in);
- QStringList INSTALLER_EXPORT retrieveStringList(QIODevice *in);
- QHash<QString,QString> INSTALLER_EXPORT retrieveDictionary(QIODevice *in);
- QByteArray INSTALLER_EXPORT retrieveData(QIODevice *in, qint64 size);
- QByteArray INSTALLER_EXPORT retrieveCompressedData(QIODevice *in, qint64 size);
-}
+#include <QFile>
+#include <QHash>
+#include <QSharedPointer>
+#include <QVector>
namespace QInstallerCreator {
class Component;
-class INSTALLER_EXPORT Archive : public QIODevice
+class INSTALLER_EXPORT Archive : public QFileDevice
{
Q_OBJECT
public:
@@ -113,7 +78,7 @@ protected:
qint64 readData(char *data, qint64 maxSize);
qint64 writeData(const char *data, qint64 maxSize);
- Range< qint64 > binarySegment() const;
+ Range<qint64> binarySegment() const;
private:
//used when when reading from the installer
@@ -135,9 +100,9 @@ public:
virtual ~Component();
static Component readFromIndexEntry(const QSharedPointer<QFile> &dev, qint64 offset);
- void writeIndexEntry(QIODevice *dev, qint64 offset) const;
+ void writeIndexEntry(QFileDevice *dev, qint64 offset) const;
- void writeData(QIODevice *dev, qint64 positionOffset) const;
+ void writeData(QFileDevice *dev, qint64 positionOffset) const;
void readData(const QSharedPointer<QFile> &dev, qint64 offset);
QByteArray name() const;
@@ -169,8 +134,8 @@ class INSTALLER_EXPORT ComponentIndex
public:
ComponentIndex();
static ComponentIndex read(const QSharedPointer<QFile> &dev, qint64 offset);
- void writeIndex(QIODevice *dev, qint64 offset) const;
- void writeComponentData(QIODevice *dev, qint64 offset) const;
+ void writeIndex(QFileDevice *dev, qint64 offset) const;
+ void writeComponentData(QFileDevice *dev, qint64 offset) const;
Component componentByName(const QByteArray &name) const;
void insertComponent(const Component &name);
void removeComponent(const QByteArray &name);
@@ -184,6 +149,18 @@ private:
namespace QInstaller {
+static const qint64 MagicInstallerMarker = 0x12023233UL;
+static const qint64 MagicUninstallerMarker = 0x12023234UL;
+
+static const qint64 MagicUpdaterMarker = 0x12023235UL;
+static const qint64 MagicPackageManagerMarker = 0x12023236UL;
+
+// this cookie is put at the end of the file to determine whether we have data
+static const quint64 MagicCookie = 0xc2630a1c99d668f8LL;
+static const quint64 MagicCookieDat = 0xc2630a1c99d668f9LL;
+
+qint64 INSTALLER_EXPORT findMagicCookie(QFile *file, quint64 magicCookie = MagicCookie);
+
struct BinaryLayout
{
QVector<Range<qint64> > metadataResourceSegments;
@@ -233,7 +210,7 @@ public:
static BinaryContent readFromApplicationFile();
static BinaryContent readFromBinary(const QString &path);
- static BinaryLayout readBinaryLayout(QIODevice *const file, qint64 cookiePos);
+ static BinaryLayout readBinaryLayout(QFile *const file, qint64 cookiePos);
int registerPerformedOperations();
OperationList performedOperations() const;
diff --git a/src/libs/installer/createlocalrepositoryoperation.cpp b/src/libs/installer/createlocalrepositoryoperation.cpp
index c8964796d..d52729d72 100644
--- a/src/libs/installer/createlocalrepositoryoperation.cpp
+++ b/src/libs/installer/createlocalrepositoryoperation.cpp
@@ -42,6 +42,7 @@
#include "binaryformat.h"
#include "errors.h"
+#include "fileio.h"
#include "fileutils.h"
#include "copydirectoryoperation.h"
#include "lib7z_facade.h"
@@ -124,7 +125,7 @@ static QString createArchive(const QString repoPath, const QString &sourceDir, c
const QString fileName = QString::fromLatin1("/%1meta.7z").arg(version);
QFile archive(repoPath + fileName);
- QInstaller::openForWrite(&archive, archive.fileName());
+ QInstaller::openForWrite(&archive);
Lib7z::createArchive(&archive, QStringList() << sourceDir);
removeFiles(sourceDir, helper); // cleanup the files we compressed
if (!archive.rename(sourceDir + fileName)) {
@@ -262,7 +263,7 @@ bool CreateLocalRepositoryOperation::performOperation()
file->seek(bl.endOfData - bl.indexSize - resourceSectionSize - resourceOffsetAndLengtSize);
const qint64 dataBlockStart = bl.endOfData - bl.dataBlockSize;
- file->seek(retrieveInt64(file.data()) + dataBlockStart);
+ file->seek(QInstaller::retrieveInt64(file.data()) + dataBlockStart);
QInstallerCreator::ComponentIndex componentIndex = QInstallerCreator::ComponentIndex::read(file,
dataBlockStart);
@@ -289,7 +290,7 @@ bool CreateLocalRepositoryOperation::performOperation()
continue;
QFile target(absoluteTargetPath + QDir::separator() + QString::fromUtf8(a->name()));
- QInstaller::openForWrite(&target, target.fileName());
+ QInstaller::openForWrite(&target);
QInstaller::blockingCopy(a.data(), &target, a->size());
helper.m_files.prepend(target.fileName());
emit outputTextChanged(helper.m_files.first());
diff --git a/src/libs/installer/fileio.cpp b/src/libs/installer/fileio.cpp
new file mode 100644
index 000000000..e8c4438c9
--- /dev/null
+++ b/src/libs/installer/fileio.cpp
@@ -0,0 +1,195 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
+#include "fileio.h"
+
+#include "errors.h"
+#include "range.h"
+
+#include <QCoreApplication>
+#include <QByteArray>
+#include <QFileDevice>
+#include <QString>
+
+qint64 QInstaller::retrieveInt64(QFileDevice *in)
+{
+ qint64 n = 0;
+ QInstaller::blockingRead(in, reinterpret_cast<char*>(&n), sizeof(n));
+ return n;
+}
+
+void QInstaller::appendInt64(QFileDevice *out, qint64 n)
+{
+ QInstaller::blockingWrite(out, reinterpret_cast<const char*>(&n), sizeof(n));
+}
+
+Range<qint64> QInstaller::retrieveInt64Range(QFileDevice *in)
+{
+ const quint64 start = QInstaller::retrieveInt64(in);
+ const quint64 length = QInstaller::retrieveInt64(in);
+ return Range<qint64>::fromStartAndLength(start, length);
+}
+
+void QInstaller::appendInt64Range(QFileDevice *out, const Range<qint64> &r)
+{
+ QInstaller::appendInt64(out, r.start());
+ QInstaller::appendInt64(out, r.length());
+}
+
+QString QInstaller::retrieveString(QFileDevice *in)
+{
+ return QString::fromUtf8(QInstaller::retrieveByteArray(in));
+}
+
+void QInstaller::appendString(QFileDevice *out, const QString &str)
+{
+ QInstaller::appendByteArray(out, str.toUtf8());
+}
+
+QByteArray QInstaller::retrieveByteArray(QFileDevice *in)
+{
+ QByteArray ba(QInstaller::retrieveInt64(in), '\0');
+ QInstaller::blockingRead(in, ba.data(), ba.size());
+ return ba;
+}
+
+void QInstaller::appendByteArray(QFileDevice *out, const QByteArray &ba)
+{
+ QInstaller::appendInt64(out, ba.size());
+ QInstaller::blockingWrite(out, ba.constData(), ba.size());
+}
+
+QByteArray QInstaller::retrieveData(QFileDevice *in, qint64 size)
+{
+ QByteArray ba(size, '\0');
+ QInstaller::blockingRead(in, ba.data(), size);
+ return ba;
+}
+
+void QInstaller::appendData(QFileDevice *out, QFileDevice *in, qint64 size)
+{
+ Q_ASSERT(!in->isSequential());
+ QInstaller::blockingCopy(in, out, size);
+}
+
+void QInstaller::openForRead(QFileDevice *dev)
+{
+ Q_ASSERT(dev);
+ if (!dev->open(QIODevice::ReadOnly)) {
+ throw Error(QCoreApplication::translate("QInstaller",
+ "Cannot open file %1 for reading: %2").arg(dev->fileName(), dev->errorString()));
+ }
+}
+
+void QInstaller::openForWrite(QFileDevice *dev)
+{
+ Q_ASSERT(dev);
+ if (!dev->open(QIODevice::WriteOnly)) {
+ throw Error(QCoreApplication::translate("QInstaller",
+ "Cannot open file %1 for writing: %2").arg(dev->fileName(), dev->errorString()));
+ }
+}
+
+void QInstaller::openForAppend(QFileDevice *dev)
+{
+ Q_ASSERT(dev);
+ if (!dev->open(QIODevice::WriteOnly | QIODevice::Append)) {
+ throw Error(QCoreApplication::translate("QInstaller",
+ "Cannot open file %1 for writing: %2").arg(dev->fileName(), dev->errorString()));
+ }
+}
+
+qint64 QInstaller::blockingRead(QFileDevice *in, char *buffer, qint64 size)
+{
+ if (in->atEnd())
+ return 0;
+ qint64 left = size;
+ while (left > 0) {
+ const qint64 n = in->read(buffer, left);
+ if (n < 0) {
+ throw Error(QCoreApplication::translate("QInstaller",
+ "Read failed after %1 bytes: %2").arg(QString::number(size - left),
+ in->errorString()));
+ }
+ left -= n;
+ buffer += n;
+ }
+ return size;
+}
+
+qint64 QInstaller::blockingCopy(QFileDevice *in, QFileDevice *out, qint64 size)
+{
+ static const qint64 blockSize = 4096;
+ QByteArray ba(blockSize, '\0');
+ qint64 actual = qMin(blockSize, size);
+ while (actual > 0) {
+ try {
+ QInstaller::blockingRead(in, ba.data(), actual);
+ QInstaller::blockingWrite(out, ba.constData(), actual);
+ size -= actual;
+ actual = qMin(blockSize, size);
+ } catch (const Error &error) {
+ throw Error(QCoreApplication::translate("QInstaller", "Copy failed. Error: %1")
+ .arg(error.message()));
+ }
+ }
+ return size;
+}
+
+qint64 QInstaller::blockingWrite(QFileDevice *out, const QByteArray &data)
+{
+ return QInstaller::blockingWrite(out, data.constData(), data.size());
+}
+
+qint64 QInstaller::blockingWrite(QFileDevice *out, const char *data, qint64 size)
+{
+ qint64 left = size;
+ while (left > 0) {
+ const qint64 n = out->write(data, left);
+ if (n < 0) {
+ throw Error(QCoreApplication::translate("QInstaller",
+ "Write failed after %1 bytes: %2").arg(QString::number(size - left),
+ out->errorString()));
+ }
+ left -= n;
+ }
+ return size;
+}
diff --git a/src/libs/installer/fileio.h b/src/libs/installer/fileio.h
new file mode 100644
index 000000000..274a62500
--- /dev/null
+++ b/src/libs/installer/fileio.h
@@ -0,0 +1,85 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
+#ifndef FILEIO_H
+#define FILEIO_H
+
+#include "installer_global.h"
+
+QT_BEGIN_NAMESPACE
+class QByteArray;
+class QFileDevice;
+class QString;
+QT_END_NAMESPACE
+
+template <typename T>
+class Range;
+
+namespace QInstaller {
+
+qint64 INSTALLER_EXPORT retrieveInt64(QFileDevice *in);
+void INSTALLER_EXPORT appendInt64(QFileDevice *out, qint64 n);
+
+Range<qint64> INSTALLER_EXPORT retrieveInt64Range(QFileDevice *in);
+void INSTALLER_EXPORT appendInt64Range(QFileDevice *out, const Range<qint64> &r);
+
+QString INSTALLER_EXPORT retrieveString(QFileDevice *in);
+void INSTALLER_EXPORT appendString(QFileDevice *out, const QString &str);
+
+QByteArray INSTALLER_EXPORT retrieveByteArray(QFileDevice *in);
+void INSTALLER_EXPORT appendByteArray(QFileDevice *out, const QByteArray &ba);
+
+QByteArray INSTALLER_EXPORT retrieveData(QFileDevice *in, qint64 size);
+void INSTALLER_EXPORT appendData(QFileDevice *out, QFileDevice *in, qint64 size);
+
+void INSTALLER_EXPORT openForRead(QFileDevice *dev);
+void INSTALLER_EXPORT openForWrite(QFileDevice *dev);
+void INSTALLER_EXPORT openForAppend(QFileDevice *dev);
+
+qint64 INSTALLER_EXPORT blockingRead(QFileDevice *in, char *buffer, qint64 size);
+qint64 INSTALLER_EXPORT blockingCopy(QFileDevice *in, QFileDevice *out, qint64 size);
+
+qint64 INSTALLER_EXPORT blockingWrite(QFileDevice *out, const QByteArray &data);
+qint64 INSTALLER_EXPORT blockingWrite(QFileDevice *out, const char *data, qint64 size);
+
+} // namespace QInstaller
+
+#endif // FILEIO_H
diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp
index 82639b7a6..76fae9d08 100644
--- a/src/libs/installer/fileutils.cpp
+++ b/src/libs/installer/fileutils.cpp
@@ -181,76 +181,6 @@ QString QInstaller::pathFromUrl(const QUrl &url)
return str;
}
-void QInstaller::openForRead(QIODevice *dev, const QString &name)
-{
- Q_ASSERT(dev);
- if (!dev->open(QIODevice::ReadOnly))
- throw Error(QObject::tr("Cannot open file %1 for reading: %2").arg(name, dev->errorString()));
-}
-
-void QInstaller::openForWrite(QIODevice *dev, const QString &name)
-{
- Q_ASSERT(dev);
- if (!dev->open(QIODevice::WriteOnly))
- throw Error(QObject::tr("Cannot open file %1 for writing: %2").arg(name, dev->errorString()));
-}
-
-void QInstaller::openForAppend(QIODevice *dev, const QString &name)
-{
- Q_ASSERT(dev);
- if (!dev->open(QIODevice::WriteOnly | QIODevice::Append))
- throw Error(QObject::tr("Cannot open file %1 for writing: %2").arg(name, dev->errorString()));
-}
-
-qint64 QInstaller::blockingWrite(QIODevice *out, const char *buffer, qint64 size)
-{
- qint64 left = size;
- while (left > 0) {
- const qint64 n = out->write(buffer, left);
- if (n < 0) {
- throw Error(QObject::tr("Write failed after %1 bytes: %2").arg(QString::number(size-left),
- out->errorString()));
- }
- left -= n;
- }
- return size;
-}
-
-qint64 QInstaller::blockingWrite(QIODevice *out, const QByteArray &ba)
-{
- return blockingWrite(out, ba.constData(), ba.size());
-}
-
-qint64 QInstaller::blockingRead(QIODevice *in, char *buffer, qint64 size)
-{
- if (in->atEnd())
- return 0;
- qint64 left = size;
- while (left > 0) {
- const qint64 n = in->read(buffer, left);
- if (n < 0) {
- throw Error(QObject::tr("Read failed after %1 bytes: %2").arg(QString::number(size-left),
- in->errorString()));
- }
- left -= n;
- buffer += n;
- }
- return size;
-}
-
-void QInstaller::blockingCopy(QIODevice *in, QIODevice *out, qint64 size)
-{
- static const qint64 blockSize = 4096;
- QByteArray ba(blockSize, '\0');
- qint64 actual = qMin(blockSize, size);
- while (actual > 0) {
- blockingRead(in, ba.data(), actual);
- blockingWrite(out, ba.constData(), actual);
- size -= actual;
- actual = qMin(blockSize, size);
- }
-}
-
void QInstaller::removeFiles(const QString &path, bool ignoreErrors)
{
const QFileInfoList entries = QDir(path).entryInfoList(QDir::AllEntries | QDir::Hidden);
diff --git a/src/libs/installer/fileutils.h b/src/libs/installer/fileutils.h
index 056cd87e0..a8efefacd 100644
--- a/src/libs/installer/fileutils.h
+++ b/src/libs/installer/fileutils.h
@@ -48,9 +48,7 @@
#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
-class QByteArray;
class QFileInfo;
-class QIODevice;
class QUrl;
QT_END_NAMESPACE
@@ -82,15 +80,6 @@ private:
QString INSTALLER_EXPORT humanReadableSize(const qint64 &size, int precision = 2);
- void INSTALLER_EXPORT openForRead(QIODevice *dev, const QString &name);
- void INSTALLER_EXPORT openForWrite(QIODevice *dev, const QString &name);
- void INSTALLER_EXPORT openForAppend(QIODevice *dev, const QString &name);
-
- qint64 INSTALLER_EXPORT blockingRead(QIODevice *in, char *buffer, qint64 size);
- void INSTALLER_EXPORT blockingCopy(QIODevice *in, QIODevice *out, qint64 size);
- qint64 INSTALLER_EXPORT blockingWrite(QIODevice *out, const char *buffer, qint64 size);
- qint64 INSTALLER_EXPORT blockingWrite(QIODevice *out, const QByteArray& ba);
-
/*!
Removes the directory at \a path recursively.
@param path The directory to remove
diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro
index 016c08f3b..42f51cdd0 100644
--- a/src/libs/installer/installer.pro
+++ b/src/libs/installer/installer.pro
@@ -119,7 +119,8 @@ HEADERS += packagemanagercore.h \
remoteserver_p.h \
remotefileengine.h \
remoteserverconnection.h \
- remoteserverconnection_p.h
+ remoteserverconnection_p.h \
+ fileio.h
SOURCES += packagemanagercore.cpp \
packagemanagercore_p.cpp \
@@ -188,7 +189,8 @@ SOURCES += packagemanagercore.cpp \
remoteclient.cpp \
remoteserver.cpp \
remotefileengine.cpp \
- remoteserverconnection.cpp
+ remoteserverconnection.cpp \
+ fileio.cpp
RESOURCES += resources/patch_file_lists.qrc \
resources/installer.qrc
diff --git a/src/libs/installer/lib7z_facade.cpp b/src/libs/installer/lib7z_facade.cpp
index de7241276..e5c47eba6 100644
--- a/src/libs/installer/lib7z_facade.cpp
+++ b/src/libs/installer/lib7z_facade.cpp
@@ -41,7 +41,7 @@
#include "lib7z_facade.h"
#include "errors.h"
-#include "fileutils.h"
+#include "fileio.h"
#ifndef Q_OS_WIN
# include "StdAfx.h"
@@ -598,7 +598,7 @@ void Job::start()
class ListArchiveJob::Private
{
public:
- QPointer<QIODevice> archive;
+ QPointer<QFileDevice> archive;
QVector<File> files;
};
@@ -613,12 +613,12 @@ ListArchiveJob::~ListArchiveJob()
delete d;
}
-QIODevice* ListArchiveJob::archive() const
+QFileDevice* ListArchiveJob::archive() const
{
return d->archive;
}
-void ListArchiveJob::setArchive(QIODevice* device)
+void ListArchiveJob::setArchive(QFileDevice* device)
{
d->archive = device;
}
@@ -631,7 +631,7 @@ QVector<File> ListArchiveJob::index() const
class OpenArchiveInfo
{
private:
- OpenArchiveInfo(QIODevice* device)
+ OpenArchiveInfo(QFileDevice* device)
: codecs(new CCodecs)
{
if (codecs->Load() != S_OK)
@@ -657,7 +657,7 @@ public:
m_cleaner->deleteLater();
}
- static OpenArchiveInfo* value(QIODevice* device)
+ static OpenArchiveInfo* value(QFileDevice* device)
{
QMutexLocker _(&m_mutex);
if (!instances.contains(device))
@@ -665,7 +665,7 @@ public:
return instances.value(device);
}
- static OpenArchiveInfo* take(QIODevice *device)
+ static OpenArchiveInfo* take(QFileDevice *device)
{
QMutexLocker _(&m_mutex);
if (instances.contains(device))
@@ -690,12 +690,12 @@ QHash< QIODevice*, OpenArchiveInfo* > OpenArchiveInfo::instances;
void OpenArchiveInfoCleaner::deviceDestroyed(QObject* dev)
{
- QIODevice* device = static_cast<QIODevice*>(dev);
+ QFileDevice* device = static_cast<QFileDevice*>(dev);
Q_ASSERT(device);
delete OpenArchiveInfo::take(device);
}
-QVector<File> Lib7z::listArchive(QIODevice* archive)
+QVector<File> Lib7z::listArchive(QFileDevice* archive)
{
assert(archive);
try {
@@ -1012,7 +1012,7 @@ const ExtractCallbackImpl* ExtractCallback::impl() const
return d->impl;
}
-void ExtractCallback::setTarget(QIODevice* dev)
+void ExtractCallback::setTarget(QFileDevice* dev)
{
d->impl->setTarget(dev);
}
@@ -1203,7 +1203,7 @@ void UpdateCallback::setSourcePaths(const QStringList &paths)
d->impl()->setSourcePaths(paths);
}
-void UpdateCallback::setTarget(QIODevice* target)
+void UpdateCallback::setTarget(QFileDevice* target)
{
d->impl()->setTarget(target);
}
@@ -1220,9 +1220,9 @@ public:
ExtractItemJob* q;
File item;
- QPointer<QIODevice> archive;
+ QPointer<QFileDevice> archive;
QString targetDirectory;
- QIODevice* target;
+ QFileDevice* target;
ExtractCallback* callback;
};
@@ -1247,12 +1247,12 @@ void ExtractItemJob::setItem(const File& item)
d->item = item;
}
-QIODevice* ExtractItemJob::archive() const
+QFileDevice* ExtractItemJob::archive() const
{
return d->archive;
}
-void ExtractItemJob::setArchive(QIODevice* archive)
+void ExtractItemJob::setArchive(QFileDevice* archive)
{
d->archive = archive;
}
@@ -1268,7 +1268,7 @@ void ExtractItemJob::setTargetDirectory(const QString &dir)
d->target = 0;
}
-void ExtractItemJob::setTarget(QIODevice* dev)
+void ExtractItemJob::setTarget(QFileDevice* dev)
{
d->target = dev;
}
@@ -1313,7 +1313,7 @@ namespace{
}
}
-void Lib7z::createArchive(QIODevice* archive, const QStringList &sourcePaths, UpdateCallback* callback)
+void Lib7z::createArchive(QFileDevice* archive, const QStringList &sourcePaths, UpdateCallback* callback)
{
assert(archive);
@@ -1381,7 +1381,7 @@ void Lib7z::createArchive(QIODevice* archive, const QStringList &sourcePaths, Up
{
//TODO remove temp file even if one the following throws
QFile file(tempFile);
- QInstaller::openForRead(&file, tempFile);
+ QInstaller::openForRead(&file);
QInstaller::blockingCopy(&file, archive, file.size());
}
@@ -1401,7 +1401,7 @@ void Lib7z::createArchive(QIODevice* archive, const QStringList &sourcePaths, Up
}
}
-void Lib7z::extractFileFromArchive(QIODevice* archive, const File& item, QIODevice* target,
+void Lib7z::extractFileFromArchive(QFileDevice* archive, const File& item, QFileDevice* target,
ExtractCallback* callback)
{
assert(archive);
@@ -1454,8 +1454,8 @@ void Lib7z::extractFileFromArchive(QIODevice* archive, const File& item, QIODevi
}
}
-void Lib7z::extractFileFromArchive(QIODevice* archive, const File& item, const QString &targetDirectory,
- ExtractCallback* callback)
+void Lib7z::extractFileFromArchive(QFileDevice* archive, const File& item,
+ const QString &targetDirectory, ExtractCallback* callback)
{
assert(archive);
@@ -1478,7 +1478,8 @@ void Lib7z::extractFileFromArchive(QIODevice* archive, const File& item, const Q
outDir.release();
}
-void Lib7z::extractArchive(QIODevice* archive, const QString &targetDirectory, ExtractCallback* callback)
+void Lib7z::extractArchive(QFileDevice* archive, const QString &targetDirectory,
+ ExtractCallback* callback)
{
assert(archive);
@@ -1517,7 +1518,7 @@ bool Lib7z::isSupportedArchive(const QString &archive)
return isSupportedArchive(&file);
}
-bool Lib7z::isSupportedArchive(QIODevice* archive)
+bool Lib7z::isSupportedArchive(QFileDevice* archive)
{
assert(archive);
assert(!archive->isSequential());
diff --git a/src/libs/installer/lib7z_facade.h b/src/libs/installer/lib7z_facade.h
index a783fbd44..46b2672a6 100644
--- a/src/libs/installer/lib7z_facade.h
+++ b/src/libs/installer/lib7z_facade.h
@@ -102,8 +102,8 @@ namespace Lib7z {
ExtractCallback();
virtual ~ExtractCallback();
- void setTarget( QIODevice* archive );
- void setTarget( const QString& dir );
+ void setTarget(QFileDevice* archive);
+ void setTarget(const QString& dir );
protected:
/**
@@ -133,8 +133,8 @@ namespace Lib7z {
UpdateCallback();
virtual ~UpdateCallback();
- void setTarget( QIODevice* archive );
- void setSourcePaths( const QStringList& paths );
+ void setTarget(QFileDevice* archive);
+ void setSourcePaths(const QStringList& paths);
virtual UpdateCallbackImpl* impl();
@@ -151,53 +151,54 @@ namespace Lib7z {
};
/*!
- Extracts the given File \a file from \a archive into output device \a out using the provided extract
- callback \a callback.
+ Extracts the given File \a file from \a archive into output device \a out using the
+ provided extract callback \a callback.
Throws Lib7z::SevenZipException on error.
*/
- void INSTALLER_EXPORT extractFileFromArchive(QIODevice* archive, const File& item, QIODevice* out,
- ExtractCallback* callback=0 );
+ void INSTALLER_EXPORT extractFileFromArchive(QFileDevice* archive, const File& item,
+ QFileDevice* out, ExtractCallback* callback=0 );
/*!
- Extracts the given File \a file from \a archive into target directory \a targetDirectory using the
- provided extract callback \a callback. The output filename is deduced from the \a file path name.
+ Extracts the given File \a file from \a archive into target directory \a targetDirectory
+ using the provided extract callback \a callback. The output filename is deduced from the
+ \a file path name.
Throws Lib7z::SevenZipException on error.
*/
- void INSTALLER_EXPORT extractFileFromArchive(QIODevice* archive, const File& item,
+ void INSTALLER_EXPORT extractFileFromArchive(QFileDevice* archive, const File& item,
const QString& targetDirectory, ExtractCallback* callback = 0);
/*!
Extracts the given \a archive content into target directory \a targetDirectory using the
- provided extract callback \a callback. The output filenames are deduced from the \a archive content.
+ provided extract callback \a callback. The output filenames are deduced from the \a archive
+ content.
Throws Lib7z::SevenZipException on error.
*/
- void INSTALLER_EXPORT extractArchive(QIODevice* archive, const QString& targetDirectory,
+ void INSTALLER_EXPORT extractArchive(QFileDevice* archive, const QString& targetDirectory,
ExtractCallback* callback = 0);
/*
* @thows Lib7z::SevenZipException
*/
- void INSTALLER_EXPORT createArchive( QIODevice* archive, const QStringList& sourcePaths, UpdateCallback* callback = 0 );
+ void INSTALLER_EXPORT createArchive(QFileDevice* archive, const QStringList& sourcePaths,
+ UpdateCallback* callback = 0 );
/*
* @throws Lib7z::SevenZipException
*/
- QVector<File> INSTALLER_EXPORT listArchive( QIODevice* archive );
+ QVector<File> INSTALLER_EXPORT listArchive(QFileDevice* archive);
/*
* @throws Lib7z::SevenZipException
*/
- bool INSTALLER_EXPORT isSupportedArchive( QIODevice* archive );
+ bool INSTALLER_EXPORT isSupportedArchive(QFileDevice* archive);
/*
* @throws Lib7z::SevenZipException
*/
- bool INSTALLER_EXPORT isSupportedArchive( const QString& archive );
-
-
+ bool INSTALLER_EXPORT isSupportedArchive(const QString& archive);
enum Error {
NoError=0,
@@ -207,7 +208,8 @@ namespace Lib7z {
class ExtractCallbackJobImpl;
- class INSTALLER_EXPORT Job : public QObject, public QRunnable {
+ class INSTALLER_EXPORT Job : public QObject, public QRunnable
+ {
friend class ::Lib7z::ExtractCallbackJobImpl;
Q_OBJECT
public:
@@ -246,8 +248,8 @@ namespace Lib7z {
explicit ListArchiveJob( QObject* parent=0 );
~ListArchiveJob();
- QIODevice* archive() const;
- void setArchive( QIODevice* archive );
+ QFileDevice* archive() const;
+ void setArchive(QFileDevice* archive);
QVector<File> index() const;
@@ -270,13 +272,13 @@ namespace Lib7z {
File item() const;
void setItem( const File& item );
- QIODevice* archive() const;
- void setArchive( QIODevice* archive );
+ QFileDevice* archive() const;
+ void setArchive(QFileDevice* archive);
QString targetDirectory() const;
void setTargetDirectory( const QString& dir );
- void setTarget( QIODevice* dev );
+ void setTarget(QFileDevice* dev);
private:
/* reimp */ void doStart();
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index 0ea6884fd..051bf8103 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -46,7 +46,7 @@
#include "scriptengine.h"
#include "componentmodel.h"
#include "errors.h"
-#include "fileutils.h"
+#include "fileio.h"
#include "remotefileengine.h"
#include "globals.h"
#include "graph.h"
@@ -149,7 +149,7 @@ static void deferredRename(const QString &oldName, const QString &newName, bool
QStringList arguments;
{
QTemporaryFile f(QDir::temp().absoluteFilePath(QLatin1String("deferredrenameXXXXXX.vbs")));
- openForWrite(&f, f.fileName());
+ QInstaller::openForWrite(&f);
f.setAutoRemove(false);
arguments << QDir::toNativeSeparators(f.fileName()) << QDir::toNativeSeparators(oldName)
@@ -1041,12 +1041,12 @@ void PackageManagerCorePrivate::writeUninstallerBinary(QFile *const input, qint6
ProgressCoordinator::instance()->emitLabelAndDetailTextChanged(tr("Writing uninstaller."));
KDSaveFile out(uninstallerRenamedName);
- openForWrite(&out, out.fileName()); // throws an exception in case of error
+ QInstaller::openForWrite(&out); // throws an exception in case of error
if (!input->seek(0))
throw Error(QObject::tr("Failed to seek in file %1: %2").arg(input->fileName(), input->errorString()));
- appendData(&out, input, size);
+ QInstaller::appendData(&out, input, size);
if (writeBinaryLayout) {
#ifdef Q_OS_MAC
QDir resourcePath(QFileInfo(uninstallerRenamedName).dir());
@@ -1058,23 +1058,23 @@ void PackageManagerCorePrivate::writeUninstallerBinary(QFile *const input, qint6
// other code a lot (since installers don't have any appended data either)
QString outPath = resourcePath.filePath(QLatin1String("installer.dat"));
KDSaveFile dataOut(outPath);
- openForWrite(&dataOut, dataOut.fileName());
- appendInt64(&dataOut, 0); // operations start
- appendInt64(&dataOut, 0); // operations end
- appendInt64(&dataOut, 0); // resource count
- appendInt64(&dataOut, 4 * sizeof(qint64)); // data block size
- appendInt64(&dataOut, QInstaller::MagicUninstallerMarker);
- appendInt64(&dataOut, QInstaller::MagicCookie);
+ QInstaller::openForWrite(&dataOut);
+ QInstaller::appendInt64(&dataOut, 0); // operations start
+ QInstaller::appendInt64(&dataOut, 0); // operations end
+ QInstaller::appendInt64(&dataOut, 0); // resource count
+ QInstaller::appendInt64(&dataOut, 4 * sizeof(qint64)); // data block size
+ QInstaller::appendInt64(&dataOut, QInstaller::MagicUninstallerMarker);
+ QInstaller::appendInt64(&dataOut, QInstaller::MagicCookie);
dataOut.setPermissions(dataOut.permissions() | QFile::WriteUser | QFile::ReadGroup | QFile::ReadOther);
if (!dataOut.commit(KDSaveFile::OverwriteExistingFile))
throw Error(tr("Could not write uninstaller data to %1: %2").arg(out.fileName(), out.errorString()));
#else
- appendInt64(&out, 0); // operations start
- appendInt64(&out, 0); // operations end
- appendInt64(&out, 0); // resource count
- appendInt64(&out, 4 * sizeof(qint64)); // data block size
- appendInt64(&out, QInstaller::MagicUninstallerMarker);
- appendInt64(&out, QInstaller::MagicCookie);
+ QInstaller::appendInt64(&out, 0); // operations start
+ QInstaller::appendInt64(&out, 0); // operations end
+ QInstaller::appendInt64(&out, 0); // resource count
+ QInstaller::appendInt64(&out, 4 * sizeof(qint64)); // data block size
+ QInstaller::appendInt64(&out, QInstaller::MagicUninstallerMarker);
+ QInstaller::appendInt64(&out, QInstaller::MagicCookie);
#endif
}
out.setPermissions(out.permissions() | QFile::WriteUser | QFile::ReadGroup | QFile::ReadOther
@@ -1084,7 +1084,7 @@ void PackageManagerCorePrivate::writeUninstallerBinary(QFile *const input, qint6
throw Error(tr("Could not write uninstaller to %1: %2").arg(out.fileName(), out.errorString()));
}
-void PackageManagerCorePrivate::writeUninstallerBinaryData(QIODevice *output, QFile *const input,
+void PackageManagerCorePrivate::writeUninstallerBinaryData(QFileDevice *output, QFile *const input,
const OperationList &performedOperations, const BinaryLayout &layout)
{
const qint64 dataBlockStart = output->pos();
@@ -1097,7 +1097,7 @@ void PackageManagerCorePrivate::writeUninstallerBinaryData(QIODevice *output, QF
QFile file(newDefaultResource);
if (file.open(QIODevice::ReadOnly)) {
resourceSegments.append(Range<qint64>::fromStartAndLength(output->pos(), file.size()));
- appendData(output, &file, file.size());
+ QInstaller::appendData(output, &file, file.size());
existingResourceSegments.remove(0);
file.remove(); // clear all possible leftovers
@@ -1111,43 +1111,43 @@ void PackageManagerCorePrivate::writeUninstallerBinaryData(QIODevice *output, QF
foreach (const Range<qint64> &segment, existingResourceSegments) {
input->seek(segment.start());
resourceSegments.append(Range<qint64>::fromStartAndLength(output->pos(), segment.length()));
- appendData(output, input, segment.length());
+ QInstaller::appendData(output, input, segment.length());
}
const qint64 operationsStart = output->pos();
- appendInt64(output, performedOperations.count());
+ QInstaller::appendInt64(output, performedOperations.count());
foreach (Operation *operation, performedOperations) {
// the installer can't be put into XML, remove it first
operation->clearValue(QLatin1String("installer"));
- appendString(output, operation->name());
- appendString(output, operation->toXml().toString());
+ QInstaller::appendString(output, operation->name());
+ QInstaller::appendString(output, operation->toXml().toString());
// for the ui not to get blocked
qApp->processEvents();
}
- appendInt64(output, performedOperations.count());
+ QInstaller::appendInt64(output, performedOperations.count());
const qint64 operationsEnd = output->pos();
// we don't save any component-indexes.
const qint64 numComponents = 0;
- appendInt64(output, numComponents); // for the indexes
+ QInstaller::appendInt64(output, numComponents); // for the indexes
// we don't save any components.
const qint64 compIndexStart = output->pos();
- appendInt64(output, numComponents); // and 2 times number of components,
- appendInt64(output, numComponents); // one before and one after the components
+ QInstaller::appendInt64(output, numComponents); // and 2 times number of components,
+ QInstaller::appendInt64(output, numComponents); // one before and one after the components
const qint64 compIndexEnd = output->pos();
- appendInt64Range(output, Range<qint64>::fromStartAndEnd(compIndexStart, compIndexEnd)
+ QInstaller::appendInt64Range(output, Range<qint64>::fromStartAndEnd(compIndexStart, compIndexEnd)
.moved(-dataBlockStart));
foreach (const Range<qint64> segment, resourceSegments)
- appendInt64Range(output, segment.moved(-dataBlockStart));
- appendInt64Range(output, Range<qint64>::fromStartAndEnd(operationsStart, operationsEnd)
+ QInstaller::appendInt64Range(output, segment.moved(-dataBlockStart));
+ QInstaller::appendInt64Range(output, Range<qint64>::fromStartAndEnd(operationsStart, operationsEnd)
.moved(-dataBlockStart));
- appendInt64(output, layout.resourceCount);
+ QInstaller::appendInt64(output, layout.resourceCount);
// data block size, from end of .exe to end of file
- appendInt64(output, output->pos() + 3 * sizeof(qint64) - dataBlockStart);
- appendInt64(output, MagicUninstallerMarker);
+ QInstaller::appendInt64(output, output->pos() + 3 * sizeof(qint64) -dataBlockStart);
+ QInstaller::appendInt64(output, MagicUninstallerMarker);
}
void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperations)
@@ -1189,9 +1189,9 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio
// patch the Info.plist after copying it
QFile sourcePlist(sourceAppDirPath + QLatin1String("/../Info.plist"));
- openForRead(&sourcePlist, sourcePlist.fileName());
+ QInstaller::openForRead(&sourcePlist);
QFile targetPlist(targetAppDirPath + QLatin1String("/../Info.plist"));
- openForWrite(&targetPlist, targetPlist.fileName());
+ QInstaller::openForWrite(&targetPlist);
QTextStream in(&sourcePlist);
QTextStream out(&targetPlist);
@@ -1282,7 +1282,7 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio
QFile replacementBinary(installerBaseBinary);
try {
- openForRead(&replacementBinary, replacementBinary.fileName());
+ QInstaller::openForRead(&replacementBinary);
writeUninstallerBinary(&replacementBinary, replacementBinary.size(), true);
qDebug() << "Wrote the binary with the new replacement.";
@@ -1318,7 +1318,7 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio
"binary resource from our very own binary!"));
}
input.setFileName(dataFile);
- openForRead(&input, input.fileName());
+ QInstaller::openForRead(&input);
layout = BinaryContent::readBinaryLayout(&input, findMagicCookie(&input, MagicCookieDat));
} catch (const Error &/*error*/) {
#ifdef Q_OS_MAC
@@ -1329,18 +1329,18 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio
dataPath.cd(QLatin1String("Resources"));
input.setFileName(dataPath.filePath(QLatin1String("installer.dat")));
- openForRead(&input, input.fileName());
+ QInstaller::openForRead(&input);
layout = BinaryContent::readBinaryLayout(&input, findMagicCookie(&input, MagicCookie));
if (!newBinaryWritten) {
newBinaryWritten = true;
QFile tmp(binaryName);
- openForRead(&tmp, tmp.fileName());
+ QInstaller::openForRead(&tmp);
writeUninstallerBinary(&tmp, tmp.size(), true);
}
#else
input.setFileName(isInstaller() ? installerBinaryPath() : uninstallerName());
- openForRead(&input, input.fileName());
+ QInstaller::openForRead(&input);
layout = BinaryContent::readBinaryLayout(&input, findMagicCookie(&input, MagicCookie));
if (!newBinaryWritten) {
newBinaryWritten = true;
@@ -1354,10 +1354,10 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio
try {
KDSaveFile file(dataFile + QLatin1String(".new"));
- openForWrite(&file, file.fileName());
+ QInstaller::openForWrite(&file);
writeUninstallerBinaryData(&file, &input, performedOperations, layout);
- appendInt64(&file, MagicCookieDat);
+ QInstaller::appendInt64(&file, MagicCookieDat);
file.setPermissions(file.permissions() | QFile::WriteUser | QFile::ReadGroup
| QFile::ReadOther);
if (!file.commit(KDSaveFile::OverwriteExistingFile)) {
@@ -1368,16 +1368,16 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio
if (!newBinaryWritten) {
newBinaryWritten = true;
QFile tmp(isInstaller() ? installerBinaryPath() : uninstallerName());
- openForRead(&tmp, tmp.fileName());
+ QInstaller::openForRead(&tmp);
BinaryLayout tmpLayout = BinaryContent::readBinaryLayout(&tmp, findMagicCookie(&tmp, MagicCookie));
writeUninstallerBinary(&tmp, tmpLayout.endOfData - tmpLayout.dataBlockSize, false);
}
QFile file(uninstallerName() + QLatin1String(".new"));
- openForAppend(&file, file.fileName());
+ QInstaller::openForAppend(&file);
file.seek(file.size());
writeUninstallerBinaryData(&file, &input, performedOperations, layout);
- appendInt64(&file, MagicCookie);
+ QInstaller::appendInt64(&file, MagicCookie);
}
input.close();
writeMaintenanceConfigFiles();
@@ -2209,7 +2209,7 @@ bool PackageManagerCorePrivate::addUpdateResourcesFromRepositories(bool parseChe
const QString updatesXmlPath = data.directory + QLatin1String("/Updates.xml");
QFile updatesFile(updatesXmlPath);
try {
- openForRead(&updatesFile, updatesFile.fileName());
+ QInstaller::openForRead(&updatesFile);
} catch(const Error &e) {
qDebug() << "Error opening Updates.xml:" << e.message();
setStatus(PackageManagerCore::Failure, tr("Could not add temporary update source information."));
diff --git a/src/libs/installer/packagemanagercore_p.h b/src/libs/installer/packagemanagercore_p.h
index 14cfd1730..4205d187f 100644
--- a/src/libs/installer/packagemanagercore_p.h
+++ b/src/libs/installer/packagemanagercore_p.h
@@ -246,8 +246,8 @@ private:
void unregisterUninstaller();
void writeUninstallerBinary(QFile *const input, qint64 size, bool writeBinaryLayout);
- void writeUninstallerBinaryData(QIODevice *output, QFile *const input, const OperationList &performed,
- const BinaryLayout &layout);
+ void writeUninstallerBinaryData(QFileDevice *output, QFile *const input,
+ const OperationList &performed, const BinaryLayout &layout);
void runUndoOperations(const OperationList &undoOperations, double undoOperationProgressSize,
bool adminRightsGained, bool deleteOperation);
diff --git a/src/libs/kdtools/kdsavefile.cpp b/src/libs/kdtools/kdsavefile.cpp
index da2d9db3a..40f2a58bb 100644
--- a/src/libs/kdtools/kdsavefile.cpp
+++ b/src/libs/kdtools/kdsavefile.cpp
@@ -258,7 +258,7 @@ public:
KDSaveFile::KDSaveFile(const QString &filename, QObject *parent)
- : QIODevice(parent), d( new Private(makeAbsolute(filename), this))
+ : QFileDevice(parent), d(new Private(makeAbsolute(filename), this))
{}
KDSaveFile::~KDSaveFile()
diff --git a/src/libs/kdtools/kdsavefile.h b/src/libs/kdtools/kdsavefile.h
index 7408892d0..1ffef2e88 100644
--- a/src/libs/kdtools/kdsavefile.h
+++ b/src/libs/kdtools/kdsavefile.h
@@ -48,7 +48,7 @@
#include <QFile>
#include <QString>
-class KDTOOLS_EXPORT KDSaveFile : public QIODevice
+class KDTOOLS_EXPORT KDSaveFile : public QFileDevice
{
Q_OBJECT
diff --git a/src/sdk/installerbase_p.cpp b/src/sdk/installerbase_p.cpp
index cfb4851b6..b55892de2 100644
--- a/src/sdk/installerbase_p.cpp
+++ b/src/sdk/installerbase_p.cpp
@@ -43,7 +43,7 @@
#include <binaryformat.h>
#include <errors.h>
-#include <fileutils.h>
+#include <fileio.h>
#include <init.h>
#include <lib7z_facade.h>
#include <qprocesswrapper.h>
@@ -154,7 +154,7 @@ int InstallerBase::replaceMaintenanceToolBinary(QStringList arguments)
try {
{
QFile installerBaseNew(newInstallerBasePath);
- QInstaller::openForAppend(&installerBaseNew, installerBaseNew.fileName());
+ QInstaller::openForAppend(&installerBaseNew);
installerBaseNew.seek(installerBaseNew.size());
QInstaller::appendInt64(&installerBaseNew, 0); // resource count
@@ -286,7 +286,7 @@ void InstallerBase::deferredRename(const QString &oldName, const QString &newNam
#ifdef Q_OS_WIN
QTemporaryFile vbScript(QDir::temp().absoluteFilePath(QLatin1String("deferredrenameXXXXXX.vbs")));
{
- openForWrite(&vbScript, vbScript.fileName());
+ QInstaller::openForWrite(&vbScript);
vbScript.setAutoRemove(false);
QTextStream batch(&vbScript);
diff --git a/tests/auto/installer/binaryformat/tst_binaryformat.cpp b/tests/auto/installer/binaryformat/tst_binaryformat.cpp
index 59f0e8e03..217c373e3 100644
--- a/tests/auto/installer/binaryformat/tst_binaryformat.cpp
+++ b/tests/auto/installer/binaryformat/tst_binaryformat.cpp
@@ -41,7 +41,7 @@
#include <binaryformat.h>
#include <errors.h>
-#include <fileutils.h>
+#include <fileio.h>
#include <QTest>
#include <QTemporaryFile>
diff --git a/tests/auto/installer/task/tst_task.cpp b/tests/auto/installer/task/tst_task.cpp
index a966671ac..45f5a5861 100644
--- a/tests/auto/installer/task/tst_task.cpp
+++ b/tests/auto/installer/task/tst_task.cpp
@@ -41,7 +41,7 @@
#include <copyfiletask.h>
#include <downloadfiletask.h>
-#include <fileutils.h>
+#include <fileio.h>
#include <QFutureWatcher>
#include <QSignalSpy>
diff --git a/tools/binarycreator/binarycreator.cpp b/tools/binarycreator/binarycreator.cpp
index e589c7309..97cd1c5b9 100644
--- a/tools/binarycreator/binarycreator.cpp
+++ b/tools/binarycreator/binarycreator.cpp
@@ -44,6 +44,7 @@
#include <binaryformat.h>
#include <errors.h>
+#include <fileio.h>
#include <fileutils.h>
#include <init.h>
#include <repository.h>
@@ -266,7 +267,7 @@ static int assemble(Input input, const QInstaller::Settings &settings)
#endif
try {
#ifdef Q_OS_MAC
- openForWrite(&out, out.fileName());
+ QInstaller::openForWrite(&out);
QFile exe(input.installerExePath);
if (!exe.copy(input.outputPath)) {
@@ -274,11 +275,11 @@ static int assemble(Input input, const QInstaller::Settings &settings)
exe.errorString()));
}
#else
- openForWrite(&out, input.outputPath);
+ QInstaller::openForWrite(&out);
QFile exe(input.installerExePath);
- openForRead(&exe, exe.fileName());
- appendFileData(&out, &exe);
+ QInstaller::openForRead(&exe);
+ QInstaller::appendData(&out, &exe, exe.size());
#endif
const qint64 dataBlockStart = out.pos();
@@ -286,24 +287,24 @@ static int assemble(Input input, const QInstaller::Settings &settings)
// append our self created resource file
QFile res(input.binaryResourcePath);
- openForRead(&res, res.fileName());
- appendFileData(&out, &res);
+ QInstaller::openForRead(&res);
+ QInstaller::appendData(&out, &res, res.size());
input.resourcePos.append(Range<qint64>::fromStartAndEnd(out.pos() - res.size(), out.pos())
.moved(-dataBlockStart));
// append given resource files
foreach (const QString &resource, input.binaryResources) {
QFile res(resource);
- openForRead(&res, res.fileName());
- appendFileData(&out, &res);
+ QInstaller::openForRead(&res);
+ QInstaller::appendData(&out, &res, res.size());
input.resourcePos.append(Range<qint64>::fromStartAndEnd(out.pos() - res.size(), out.pos())
.moved(-dataBlockStart));
}
// zero operations cause we are not the uninstaller
const qint64 operationsStart = out.pos();
- appendInt64(&out, 0);
- appendInt64(&out, 0);
+ QInstaller::appendInt64(&out, 0);
+ QInstaller::appendInt64(&out, 0);
input.operationsPos = Range<qint64>::fromStartAndEnd(operationsStart, out.pos())
.moved(-dataBlockStart);
@@ -316,16 +317,16 @@ static int assemble(Input input, const QInstaller::Settings &settings)
qDebug("Component index: [%llu:%llu]", input.componentIndexSegment.start(),
input.componentIndexSegment.end());
- appendInt64Range(&out, input.componentIndexSegment);
+ QInstaller::appendInt64Range(&out, input.componentIndexSegment);
foreach (const Range<qint64> &range, input.resourcePos)
- appendInt64Range(&out, range);
- appendInt64Range(&out, input.operationsPos);
- appendInt64(&out, input.resourcePos.count());
+ QInstaller::appendInt64Range(&out, range);
+ QInstaller::appendInt64Range(&out, input.operationsPos);
+ QInstaller::appendInt64(&out, input.resourcePos.count());
//data block size, from end of .exe to end of file
- appendInt64(&out, out.pos() + 3 * sizeof(qint64) - dataBlockStart);
- appendInt64(&out, QInstaller::MagicInstallerMarker);
- appendInt64(&out, QInstaller::MagicCookie);
+ QInstaller::appendInt64(&out, out.pos() + 3 * sizeof(qint64) -dataBlockStart);
+ QInstaller::appendInt64(&out, QInstaller::MagicInstallerMarker);
+ QInstaller::appendInt64(&out, QInstaller::MagicCookie);
} catch (const Error &e) {
qCritical("Error occurred while assembling the installer: %s", qPrintable(e.message()));
@@ -506,7 +507,7 @@ void copyConfigData(const QString &configFile, const QString &targetDir)
QInstallerTools::copyWithException(sourceConfigFile, targetConfigFile, QLatin1String("configuration"));
QFile configXml(targetConfigFile);
- QInstaller::openForRead(&configXml, configXml.fileName());
+ QInstaller::openForRead(&configXml);
QDomDocument dom;
dom.setContent(&configXml);
@@ -553,7 +554,7 @@ void copyConfigData(const QString &configFile, const QString &targetDir)
QInstallerTools::copyWithException(elementFileInfo.absoluteFilePath(), targetFile, tagName);
}
- QInstaller::openForWrite(&configXml, configXml.fileName());
+ QInstaller::openForWrite(&configXml);
QTextStream stream(&configXml);
dom.save(stream, 4);
diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp
index b99b538f9..e8db8c1d4 100644
--- a/tools/common/repositorygen.cpp
+++ b/tools/common/repositorygen.cpp
@@ -40,6 +40,7 @@
**************************************************************************/
#include "repositorygen.h"
+#include <fileio.h>
#include <fileutils.h>
#include <errors.h>
#include <globals.h>
@@ -102,7 +103,7 @@ void QInstallerTools::copyWithException(const QString &source, const QString &ta
void QInstallerTools::compressPaths(const QStringList &paths, const QString &archivePath)
{
QFile archive(archivePath);
- QInstaller::openForWrite(&archive, archivePath);
+ QInstaller::openForWrite(&archive);
Lib7z::createArchive(&archive, paths);
}
@@ -178,7 +179,7 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met
packageXmlPath);
QFile file(packageXmlPath);
- QInstaller::openForRead(&file, packageXmlPath);
+ QInstaller::openForRead(&file);
QString errMsg;
int line = 0;
@@ -262,7 +263,7 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met
// if it's an archive already, list its files and sum the uncompressed sizes
QFile archive(fi.filePath());
compressedComponentSize += archive.size();
- QInstaller::openForRead(&archive, archive.fileName());
+ QInstaller::openForRead(&archive);
QVector<Lib7z::File>::const_iterator fileIt;
const QVector<Lib7z::File> files = Lib7z::listArchive(&archive);
@@ -385,7 +386,7 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met
doc.appendChild(root);
QFile targetUpdatesXml(targetDir + QLatin1String("/Updates.xml"));
- QInstaller::openForWrite(&targetUpdatesXml, targetUpdatesXml.fileName());
+ QInstaller::openForWrite(&targetUpdatesXml);
QInstaller::blockingWrite(&targetUpdatesXml, doc.toByteArray());
}
@@ -561,7 +562,7 @@ void QInstallerTools::compressMetaDirectories(const QString &repoDir, const QStr
}
}
- QInstaller::openForWrite(&existingUpdatesXml, existingUpdatesXml.fileName());
+ QInstaller::openForWrite(&existingUpdatesXml);
QInstaller::blockingWrite(&existingUpdatesXml, doc.toByteArray());
existingUpdatesXml.close();
}
@@ -630,12 +631,12 @@ void QInstallerTools::copyComponentData(const QStringList &packageDirs, const QS
qDebug() << "Creating hash of archive" << archiveFile.fileName();
try {
- QInstaller::openForRead(&archiveFile, archiveFile.fileName());
+ QInstaller::openForRead(&archiveFile);
const QByteArray hashOfArchiveData = QInstaller::calculateHash(&archiveFile,
QCryptographicHash::Sha1).toHex();
archiveFile.close();
- QInstaller::openForWrite(&archiveHashFile, archiveHashFile.fileName());
+ QInstaller::openForWrite(&archiveHashFile);
archiveHashFile.write(hashOfArchiveData);
qDebug() << "Generated sha1 hash:" << hashOfArchiveData;
(*infos)[i].copiedFiles.append(archiveHashFile.fileName());