summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/installer/binaryformat.cpp92
-rw-r--r--src/libs/installer/binaryformat.h2
-rw-r--r--src/libs/installer/installer.pro2
-rw-r--r--src/libs/installer/zipjob.cpp215
-rw-r--r--src/libs/installer/zipjob.h109
5 files changed, 0 insertions, 420 deletions
diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp
index 7aa4d94ab..be5ff843b 100644
--- a/src/libs/installer/binaryformat.cpp
+++ b/src/libs/installer/binaryformat.cpp
@@ -45,7 +45,6 @@
#include "fileutils.h"
#include "lib7z_facade.h"
#include "utils.h"
-#include "zipjob.h"
#include <kdupdaterupdateoperationfactory.h>
@@ -60,14 +59,6 @@
using namespace QInstaller;
using namespace QInstallerCreator;
-/*
-TRANSLATOR QInstallerCreator::Archive
-*/
-
-/*
-TRANSLATOR QInstallerCreator::Component
-*/
-
static inline QByteArray &theBuffer(int size)
{
static QByteArray b;
@@ -88,9 +79,6 @@ void QInstaller::retrieveFileData(QIODevice *out, QIODevice *in)
{
qint64 size = QInstaller::retrieveInt64(in);
appendData(in, out, size);
-/* QByteArray &b = theBuffer(size);
- blockingRead(in, b.data(), size);
- blockingWrite(out, b.constData(), size);*/
}
void QInstaller::appendInt64(QIODevice *out, qint64 n)
@@ -302,58 +290,6 @@ Archive::~Archive()
}
/*!
- Copies the archives contents to the path \a name.
- If the archive is a zipped directory, \a name is treated as a directory. The archive gets extracted there.
-
- If the archive is a plain file and \a name an existing directory, it gets created
- with it's name. Otherwise it gets saved as \a name.
- Note that if a file with the \a name already exists, copy() return false (i.e. Archive will not overwrite it).
- */
-bool Archive::copy(const QString &name)
-{
- const QFileInfo fileInfo(name);
- if (isZippedDirectory()) {
- if (fileInfo.exists() && !fileInfo.isDir())
- return false;
-
- errno = 0;
- const QString absoluteFilePath = fileInfo.absoluteFilePath();
- if (!fileInfo.exists() && !QDir().mkpath(absoluteFilePath)) {
-#if defined(Q_OS_WIN) && !defined(Q_CC_MINGW)
- char msg[128];
- if (strerror_s(msg, sizeof msg, errno) != 0)
- setErrorString(tr("Could not create %1: %2").arg(name, QString::fromLocal8Bit(msg)));
-#else
- setErrorString(tr("Could not create %1: %2").arg(name, QString::fromLocal8Bit(strerror(errno))));
-#endif
- return false;
- }
-
- if (isOpen())
- close();
- open(QIODevice::ReadOnly);
-
- UnzipJob job;
- job.setInputDevice(this);
- job.setOutputPath(absoluteFilePath);
- job.run();
- } else {
- if (isOpen())
- close();
- open(QIODevice::ReadOnly);
-
- QFile target(fileInfo.isDir() ? QString::fromLatin1("%1/%2").arg(name)
- .arg(QString::fromUtf8(m_name.data(), m_name.count())) : name);
- if (target.exists())
- return false;
- target.open(QIODevice::WriteOnly);
- blockingCopy(this, &target, size());
- }
- close();
- return true;
-}
-
-/*!
\reimp
*/
bool Archive::seek(qint64 pos)
@@ -363,34 +299,6 @@ bool Archive::seek(qint64 pos)
return QIODevice::seek(pos);
}
-/*!
- Returns true, if this archive was created by zipping a directory.
- */
-bool Archive::isZippedDirectory() const
-{
- if (m_device == 0) {
- // easy, just check whether it's a dir
- return QFileInfo(m_path).isDir();
- }
-
- // more complex, check the zip header magic
- Archive* const arch = const_cast<Archive*> (this);
-
- const bool notOpened = !isOpen();
- if (notOpened)
- arch->open(QIODevice::ReadOnly);
- const qint64 p = pos();
- arch->seek(0);
-
- const QByteArray ba = arch->read(4);
- const bool result = ba == QByteArray("\x50\x4b\x03\04");
-
- arch->seek(p);
- if (notOpened)
- arch->close();
- return result;
-}
-
QByteArray Archive::name() const
{
return m_name;
diff --git a/src/libs/installer/binaryformat.h b/src/libs/installer/binaryformat.h
index 0abe78030..c3d8dbde9 100644
--- a/src/libs/installer/binaryformat.h
+++ b/src/libs/installer/binaryformat.h
@@ -105,8 +105,6 @@ public:
qint64 size() const;
bool createZippedFile();
- bool isZippedDirectory() const;
- bool copy(const QString &name);
QByteArray name() const;
void setName(const QByteArray &name);
diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro
index 837196c5f..54ff619d6 100644
--- a/src/libs/installer/installer.pro
+++ b/src/libs/installer/installer.pro
@@ -44,7 +44,6 @@ HEADERS += packagemanagercore.h \
binaryformatengine.h \
binaryformatenginehandler.h \
repository.h \
- zipjob.h \
utils.h \
errors.h \
component.h \
@@ -121,7 +120,6 @@ HEADERS += packagemanagercore.h \
binaryformatengine.cpp \
binaryformatenginehandler.cpp \
repository.cpp \
- zipjob.cpp \
fileutils.cpp \
utils.cpp \
component.cpp \
diff --git a/src/libs/installer/zipjob.cpp b/src/libs/installer/zipjob.cpp
deleted file mode 100644
index 413d1e01e..000000000
--- a/src/libs/installer/zipjob.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/**************************************************************************
-**
-** Copyright (C) 2012-2013 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 <zipjob.h>
-
-#include <QtCore/QDebug>
-#include <QtCore/QDir>
-#include <QtCore/QMetaType>
-#include <QtCore/QStringList>
-
-#include <cassert>
-#include <climits>
-
-class ZipJob::Private
-{
-public:
- Private() : outputDevice(0), process(0) {}
-
- QIODevice *outputDevice;
- QDir workingDir;
- QProcess *process;
- QStringList filesToArchive;
-};
-
-Q_DECLARE_METATYPE(QProcess::ExitStatus)
-
-ZipJob::ZipJob()
- : d(new Private())
-{
- qRegisterMetaType<QProcess::ExitStatus>();
-}
-
-ZipJob::~ZipJob()
-{
- delete d;
-}
-
-void ZipJob::run()
-{
- assert(!d->process);
- d->process = new QProcess;
- d->process->setWorkingDirectory(d->workingDir.absolutePath());
- QStringList args;
- args << QLatin1String( "-" ) << QLatin1String( "-r" ) << d->filesToArchive;
- connect(d->process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
- connect(d->process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
- connect(d->process, SIGNAL(readyReadStandardOutput()), this, SLOT(processReadyReadStandardOutput()));
-
- d->process->start(QLatin1String("zip"), args);
- if (!d->process->waitForStarted()) {
- //TODO handle
- }
-
- if (!d->process->waitForFinished(INT_MAX)) {
- //TODO handle
- }
-
- delete d->process;
- d->process = 0;
- // emit result
-}
-
-void ZipJob::processError(QProcess::ProcessError)
-{
- emit error();
-}
-
-void ZipJob::processFinished(int, QProcess::ExitStatus)
-{
- emit finished();
-}
-
-void ZipJob::processReadyReadStandardOutput()
-{
- const QByteArray buf = d->process->readAll();
- const qint64 toWrite = buf.size();
- qint64 written = 0;
- while (written < toWrite) {
- const qint64 num = d->outputDevice->write(buf.constData() + written, toWrite - written);
- if (num < 0) {
- //TODO: handle error
- return;
- }
- written += num;
- }
-}
-
-void ZipJob::setOutputDevice(QIODevice *device)
-{
- d->outputDevice = device;
-}
-
-void ZipJob::setWorkingDirectory(const QDir &dir)
-{
- d->workingDir = dir;
-}
-
-void ZipJob::setFilesToArchive(const QStringList &files)
-{
- d->filesToArchive = files;
-}
-
-class UnzipJob::Private
-{
-public:
- Private() : inputDevice(0) {}
-
- QIODevice *inputDevice;
- QString outputPath;
- QStringList filesToExtract;
-};
-
-UnzipJob::UnzipJob()
- : d(new Private())
-{
- qRegisterMetaType<QProcess::ExitStatus>();
-}
-
-UnzipJob::~UnzipJob()
-{
- delete d;
-}
-
-void UnzipJob::setInputDevice(QIODevice *device)
-{
- d->inputDevice = device;
-}
-
-void UnzipJob::setOutputPath(const QString &path)
-{
- d->outputPath = path;
-}
-
-void UnzipJob::processError(QProcess::ProcessError)
-{
- emit error();
-}
-
-void UnzipJob::run()
-{
- QProcess process;
- // TODO: this won't work on Windows... grmpfl, but on Mac and Linux, at least...
- QStringList args;
- args << QLatin1String( "/dev/stdin" );
- if (!d->filesToExtract.isEmpty())
- args << QLatin1String("-x") << d->filesToExtract;
- process.setWorkingDirectory(d->outputPath);
- process.start(QLatin1String("unzip"), args);
- connect(&process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
- connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus )));
- if (!process.waitForStarted()) {
- // TODO handle
- return;
- }
-
- const int bufferSize = 4096;
- QByteArray buffer;
- while (d->inputDevice->bytesAvailable() > 0 || d->inputDevice->waitForReadyRead(INT_MAX)) {
- buffer = d->inputDevice->read(bufferSize);
- process.write(buffer);
- process.waitForBytesWritten(INT_MAX);
- }
- process.closeWriteChannel();
-
- if (!process.waitForFinished(INT_MAX)) {
- // TODO handle
- }
-}
-
-void UnzipJob::processFinished(int, QProcess::ExitStatus)
-{
- emit finished();
-}
-
-void UnzipJob::setFilesToExtract(const QStringList &files)
-{
- d->filesToExtract = files;
-}
diff --git a/src/libs/installer/zipjob.h b/src/libs/installer/zipjob.h
deleted file mode 100644
index a0c2ecbb1..000000000
--- a/src/libs/installer/zipjob.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/**************************************************************************
-**
-** Copyright (C) 2012-2013 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 ZIPJOB_H
-#define ZIPJOB_H
-
-#include <QProcess>
-#include <QRunnable>
-
-QT_BEGIN_NAMESPACE
-class QDir;
-class QIODevice;
-class QStringList;
-QT_END_NAMESPACE
-
-class ZipJob : public QObject, public QRunnable
-{
- Q_OBJECT
-
-public:
- ZipJob();
- ~ZipJob();
-
- void setOutputDevice(QIODevice *device);
- void setWorkingDirectory(const QDir &dir);
- void setFilesToArchive(const QStringList &files);
-
- void run();
-
-Q_SIGNALS:
- void finished();
- void error();
-
-private Q_SLOTS:
- void processError(QProcess::ProcessError);
- void processFinished(int, QProcess::ExitStatus);
- void processReadyReadStandardOutput();
-
-private:
- class Private;
- Private *const d;
-};
-
-class UnzipJob : public QObject, public QRunnable
-{
- Q_OBJECT
-
-public:
- UnzipJob();
- ~UnzipJob();
-
- void setInputDevice(QIODevice *device);
- void setOutputPath(const QString &path);
- void setFilesToExtract(const QStringList &files);
-
- void run();
-
-Q_SIGNALS:
- void finished();
- void error();
-
-private Q_SLOTS:
- void processError(QProcess::ProcessError);
- void processFinished(int, QProcess::ExitStatus);
-
-private:
- class Private;
- Private *const d;
-};
-
-#endif // ZIPJOB_H