summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-06-23 13:15:15 +0200
committerKarsten Heimrich <karsten.heimrich@digia.com>2014-06-24 10:31:08 +0200
commit924ebcdbc9b9e590a5f0905941e2d05ac34d4be2 (patch)
treee57fb26ece9f67e1c59f0967198350d0a511637a /tools
parent4d8d708f98172e0e49fb2f0aad2e22d7798318e5 (diff)
Split out the file IO stuff and adjust other files respectively.
Also adjust the API to use QFileDevice instead of QIODevice to make clear we just operate on files here and not on any possible device like sockets, processes etc... Change-Id: I4ecbb6e244fe4bb666ed12e62f9f5586bc1347f0 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/binarycreator/binarycreator.cpp39
-rw-r--r--tools/common/repositorygen.cpp15
2 files changed, 28 insertions, 26 deletions
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());