Hello community, here is the log from the commit of package karchive for openSUSE:Factory checked in at 2014-11-11 01:09:46 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/karchive (Old) and /work/SRC/openSUSE:Factory/.karchive.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "karchive" Changes: -------- --- /work/SRC/openSUSE:Factory/karchive/karchive.changes 2014-10-07 16:00:12.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.karchive.new/karchive.changes 2014-11-11 01:09:55.000000000 +0100 @@ -1,0 +2,8 @@ +Sun Nov 2 17:47:22 UTC 2014 - [email protected] + +- Update to 5.4.0 + * Add support for rcc files + * For more details please see: + https://www.kde.org/announcements/kde-frameworks-5.4.0.php + +------------------------------------------------------------------- Old: ---- karchive-5.3.0.tar.xz New: ---- karchive-5.4.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ karchive.spec ++++++ --- /var/tmp/diff_new_pack.HDtOPn/_old 2014-11-11 01:09:56.000000000 +0100 +++ /var/tmp/diff_new_pack.HDtOPn/_new 2014-11-11 01:09:56.000000000 +0100 @@ -18,10 +18,10 @@ %define lname libKF5Archive5 Name: karchive -Version: 5.3.0 +Version: 5.4.0 Release: 0 BuildRequires: cmake >= 2.8.12 -BuildRequires: extra-cmake-modules >= 1.3.0 +BuildRequires: extra-cmake-modules >= 1.4.0 BuildRequires: fdupes BuildRequires: kf5-filesystem BuildRequires: pkgconfig(Qt5Core) >= 5.2.0 @@ -32,7 +32,7 @@ License: LGPL-2.1+ Group: System/GUI/KDE Url: http://www.kde.org -Source: http://download.kde.org/stable/frameworks/%{version}/%{name}-%{version}.tar.xz +Source: http://download.kde.org/stable/frameworks/5.4/%{name}-%{version}.tar.xz Source1: baselibs.conf BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ karchive-5.3.0.tar.xz -> karchive-5.4.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/CMakeLists.txt new/karchive-5.4.0/CMakeLists.txt --- old/karchive-5.3.0/CMakeLists.txt 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/CMakeLists.txt 2014-10-31 21:15:18.000000000 +0100 @@ -2,7 +2,7 @@ project(KArchive) -find_package(ECM 1.3.0 REQUIRED NO_MODULE) +find_package(ECM 1.4.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) @@ -45,7 +45,7 @@ include(ECMSetupVersion) include(ECMGenerateHeaders) -set(KF5_VERSION "5.3.0") # handled by release scripts +set(KF5_VERSION "5.4.0") # handled by release scripts ecm_setup_version(${KF5_VERSION} VARIABLE_PREFIX KARCHIVE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/autotests/karchivetest.cpp new/karchive-5.4.0/autotests/karchivetest.cpp --- old/karchive-5.3.0/autotests/karchivetest.cpp 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/autotests/karchivetest.cpp 2014-10-31 21:15:18.000000000 +0100 @@ -22,6 +22,7 @@ #include <ktar.h> #include <kzip.h> #include <k7zip.h> +#include <krcc.h> #include <QtTest/QtTest> #include <QtCore/QFileInfo> @@ -1019,6 +1020,24 @@ } } +void KArchiveTest::testRcc() +{ + const QString rccFile = QFINDTESTDATA("runtime_resource.rcc"); // was copied from qtbase/tests/auto/corelib/io/qresourceengine + QVERIFY(!rccFile.isEmpty()); + KRcc rcc(rccFile); + QVERIFY(rcc.open(QIODevice::ReadOnly)); + const KArchiveDirectory *rootDir = rcc.directory(); + QVERIFY(rootDir != 0); + const KArchiveEntry *rrEntry = rootDir->entry("runtime_resource"); + QVERIFY(rrEntry && rrEntry->isDirectory()); + const KArchiveDirectory *rrDir = static_cast<const KArchiveDirectory *>(rrEntry); + const KArchiveEntry *fileEntry = rrDir->entry("search_file.txt"); + QVERIFY(fileEntry && fileEntry->isFile()); + const KArchiveFile *searchFile = static_cast<const KArchiveFile *>(fileEntry); + const QByteArray fileData = searchFile->data(); + QCOMPARE(QString::fromLatin1(fileData), QString::fromLatin1("root\n")); +} + /** * @see QTest::cleanupTestCase() */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/autotests/karchivetest.h new/karchive-5.4.0/autotests/karchivetest.h --- old/karchive-5.3.0/autotests/karchivetest.h 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/autotests/karchivetest.h 2014-10-31 21:15:18.000000000 +0100 @@ -88,6 +88,8 @@ void testZipWithOverwrittenFileName(); void testZipAddLocalDirectory(); + void testRcc(); + #if HAVE_XZ_SUPPORT void testCreate7Zip_data() { Files old/karchive-5.3.0/autotests/runtime_resource.rcc and new/karchive-5.4.0/autotests/runtime_resource.rcc differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/CMakeLists.txt new/karchive-5.4.0/src/CMakeLists.txt --- old/karchive-5.3.0/src/CMakeLists.txt 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/src/CMakeLists.txt 2014-10-31 21:15:18.000000000 +0100 @@ -32,6 +32,7 @@ knonefilter.cpp ktar.cpp kzip.cpp + krcc.cpp ) add_library(KF5Archive ${karchive_SRCS} ${karchive_OPTIONAL_SRCS}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/kar.h new/karchive-5.4.0/src/kar.h --- old/karchive-5.3.0/src/kar.h 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/src/kar.h 2014-10-31 21:15:18.000000000 +0100 @@ -52,20 +52,20 @@ protected: /* - * Writing not supported by this class, will always fail. + * Writing is not supported by this class, will always fail. * @return always false */ bool doPrepareWriting(const QString &name, const QString &user, const QString &group, qint64 size, mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime) Q_DECL_OVERRIDE; /* - * Writing not supported by this class, will always fail. + * Writing is not supported by this class, will always fail. * @return always false */ bool doFinishWriting(qint64 size) Q_DECL_OVERRIDE; /* - * Writing not supported by this class, will always fail. + * Writing is not supported by this class, will always fail. * @return always false */ bool doWriteDir(const QString &name, const QString &user, const QString &group, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/karchivedirectory.h new/karchive-5.4.0/src/karchivedirectory.h --- old/karchive-5.3.0/src/karchivedirectory.h 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/src/karchivedirectory.h 2014-10-31 21:15:18.000000000 +0100 @@ -103,7 +103,7 @@ * Checks whether this entry is a directory. * @return true, since this entry is a directory */ - virtual bool isDirectory() const; + bool isDirectory() const Q_DECL_OVERRIDE; /** * Extracts all entries in this archive directory to the directory diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/karchivefile.h new/karchive-5.4.0/src/karchivefile.h --- old/karchive-5.3.0/src/karchivefile.h 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/src/karchivefile.h 2014-10-31 21:15:18.000000000 +0100 @@ -94,7 +94,7 @@ * Checks whether this entry is a file. * @return true, since this entry is a file */ - virtual bool isFile() const; + bool isFile() const Q_DECL_OVERRIDE; /** * Extracts the file to the directory @p dest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/kbzip2filter.h new/karchive-5.4.0/src/kbzip2filter.h --- old/karchive-5.3.0/src/kbzip2filter.h 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/src/kbzip2filter.h 2014-10-31 21:15:18.000000000 +0100 @@ -36,24 +36,24 @@ KBzip2Filter(); virtual ~KBzip2Filter(); - virtual bool init(int); - virtual int mode() const; - virtual bool terminate(); - virtual void reset(); - virtual bool readHeader() + bool init(int) Q_DECL_OVERRIDE; + int mode() const Q_DECL_OVERRIDE; + bool terminate() Q_DECL_OVERRIDE; + void reset() Q_DECL_OVERRIDE; + bool readHeader() Q_DECL_OVERRIDE { return true; // bzip2 handles it by itself ! Cool ! } - virtual bool writeHeader(const QByteArray &) + bool writeHeader(const QByteArray &) Q_DECL_OVERRIDE { return true; } - virtual void setOutBuffer(char *data, uint maxlen); - virtual void setInBuffer(const char *data, uint size); - virtual int inBufferAvailable() const; - virtual int outBufferAvailable() const; - virtual Result uncompress(); - virtual Result compress(bool finish); + void setOutBuffer(char *data, uint maxlen) Q_DECL_OVERRIDE; + void setInBuffer(const char *data, uint size) Q_DECL_OVERRIDE; + int inBufferAvailable() const Q_DECL_OVERRIDE; + int outBufferAvailable() const Q_DECL_OVERRIDE; + Result uncompress() Q_DECL_OVERRIDE; + Result compress(bool finish) Q_DECL_OVERRIDE; private: class Private; Private *const d; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/kcompressiondevice.h new/karchive-5.4.0/src/kcompressiondevice.h --- old/karchive-5.3.0/src/kcompressiondevice.h 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/src/kcompressiondevice.h 2014-10-31 21:15:18.000000000 +0100 @@ -68,12 +68,12 @@ /** * Open for reading or writing. */ - virtual bool open(QIODevice::OpenMode mode); + bool open(QIODevice::OpenMode mode) Q_DECL_OVERRIDE; /** * Close after reading or writing. */ - virtual void close(); + void close() Q_DECL_OVERRIDE; /** * For writing gzip compressed files only: @@ -92,9 +92,9 @@ /** * That one can be quite slow, when going back. Use with care. */ - virtual bool seek(qint64); + bool seek(qint64) Q_DECL_OVERRIDE; - virtual bool atEnd() const; + bool atEnd() const Q_DECL_OVERRIDE; /** * Call this to create the appropriate filter for the CompressionType @@ -107,8 +107,8 @@ protected: friend class K7Zip; - virtual qint64 readData(char *data, qint64 maxlen); - virtual qint64 writeData(const char *data, qint64 len); + qint64 readData(char *data, qint64 maxlen) Q_DECL_OVERRIDE; + qint64 writeData(const char *data, qint64 len) Q_DECL_OVERRIDE; KFilterBase *filterBase(); private: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/kgzipfilter.h new/karchive-5.4.0/src/kgzipfilter.h --- old/karchive-5.3.0/src/kgzipfilter.h 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/src/kgzipfilter.h 2014-10-31 21:15:18.000000000 +0100 @@ -35,7 +35,7 @@ KGzipFilter(); virtual ~KGzipFilter(); - virtual bool init(int mode); + bool init(int mode) Q_DECL_OVERRIDE; // The top of zlib.h explains it: there are three cases. // - Raw deflate, no header (e.g. inside a ZIP file) @@ -50,18 +50,18 @@ GZipHeader = 2 }; bool init(int mode, Flag flag); // for direct users of KGzipFilter - virtual int mode() const; - virtual bool terminate(); - virtual void reset(); - virtual bool readHeader(); // this is about the GZIP header - virtual bool writeHeader(const QByteArray &fileName); + int mode() const Q_DECL_OVERRIDE; + bool terminate() Q_DECL_OVERRIDE; + void reset() Q_DECL_OVERRIDE; + bool readHeader() Q_DECL_OVERRIDE; // this is about the GZIP header + bool writeHeader(const QByteArray &fileName) Q_DECL_OVERRIDE; void writeFooter(); - virtual void setOutBuffer(char *data, uint maxlen); - virtual void setInBuffer(const char *data, uint size); - virtual int inBufferAvailable() const; - virtual int outBufferAvailable() const; - virtual Result uncompress(); - virtual Result compress(bool finish); + void setOutBuffer(char *data, uint maxlen) Q_DECL_OVERRIDE; + void setInBuffer(const char *data, uint size) Q_DECL_OVERRIDE; + int inBufferAvailable() const Q_DECL_OVERRIDE; + int outBufferAvailable() const Q_DECL_OVERRIDE; + Result uncompress() Q_DECL_OVERRIDE; + Result compress(bool finish) Q_DECL_OVERRIDE; private: Result uncompress_noop(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/klimitediodevice_p.h new/karchive-5.4.0/src/klimitediodevice_p.h --- old/karchive-5.3.0/src/klimitediodevice_p.h 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/src/klimitediodevice_p.h 2014-10-31 21:15:18.000000000 +0100 @@ -41,26 +41,22 @@ KLimitedIODevice(QIODevice *dev, qint64 start, qint64 length); virtual ~KLimitedIODevice() {} - virtual bool isSequential() const; + bool isSequential() const Q_DECL_OVERRIDE; - virtual bool open(QIODevice::OpenMode m); - virtual void close(); + bool open(QIODevice::OpenMode m) Q_DECL_OVERRIDE; + void close() Q_DECL_OVERRIDE; - virtual qint64 size() const; + qint64 size() const Q_DECL_OVERRIDE; - virtual qint64 readData(char *data, qint64 maxlen); - virtual qint64 writeData(const char *, qint64) - { - return -1; // unsupported - } - virtual int putChar(int) + qint64 readData(char *data, qint64 maxlen) Q_DECL_OVERRIDE; + qint64 writeData(const char *, qint64) Q_DECL_OVERRIDE { return -1; // unsupported } //virtual qint64 pos() const { return m_dev->pos() - m_start; } - virtual bool seek(qint64 pos); - virtual qint64 bytesAvailable() const; + bool seek(qint64 pos) Q_DECL_OVERRIDE; + qint64 bytesAvailable() const Q_DECL_OVERRIDE; private: QIODevice *m_dev; qint64 m_start; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/knonefilter.h new/karchive-5.4.0/src/knonefilter.h --- old/karchive-5.3.0/src/knonefilter.h 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/src/knonefilter.h 2014-10-31 21:15:18.000000000 +0100 @@ -38,18 +38,18 @@ KNoneFilter(); virtual ~KNoneFilter(); - virtual bool init(int mode); - virtual int mode() const; - virtual bool terminate(); - virtual void reset(); - virtual bool readHeader(); // this is about the GZIP header - virtual bool writeHeader(const QByteArray &fileName); - virtual void setOutBuffer(char *data, uint maxlen); - virtual void setInBuffer(const char *data, uint size); - virtual int inBufferAvailable() const; - virtual int outBufferAvailable() const; - virtual Result uncompress(); - virtual Result compress(bool finish); + bool init(int mode) Q_DECL_OVERRIDE; + int mode() const Q_DECL_OVERRIDE; + bool terminate() Q_DECL_OVERRIDE; + void reset() Q_DECL_OVERRIDE; + bool readHeader() Q_DECL_OVERRIDE; // this is about the GZIP header + bool writeHeader(const QByteArray &fileName) Q_DECL_OVERRIDE; + void setOutBuffer(char *data, uint maxlen) Q_DECL_OVERRIDE; + void setInBuffer(const char *data, uint size) Q_DECL_OVERRIDE; + int inBufferAvailable() const Q_DECL_OVERRIDE; + int outBufferAvailable() const Q_DECL_OVERRIDE; + Result uncompress() Q_DECL_OVERRIDE; + Result compress(bool finish) Q_DECL_OVERRIDE; private: Result copyData(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/krcc.cpp new/karchive-5.4.0/src/krcc.cpp --- old/karchive-5.3.0/src/krcc.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/karchive-5.4.0/src/krcc.cpp 2014-10-31 21:15:18.000000000 +0100 @@ -0,0 +1,159 @@ +/* This file is part of the KDE libraries + Copyright (C) 2014 David Faure <[email protected]> + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2 of the License or + ( at your option ) version 3 or, at the discretion of KDE e.V. + ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "krcc.h" +#include "karchive_p.h" + +#include <QtCore/QFile> +#include <QtCore/QDebug> +#include <QUuid> +#include <QDateTime> +#include <QFileInfo> +#include <QResource> +#include <QDir> + +class KRcc::KRccPrivate +{ +public: + KRccPrivate() {} + void createEntries(const QDir &dir, KArchiveDirectory *parentDir, KRcc* q); + + QString m_prefix; // '/' + uuid +}; + +/** + * A KRccFileEntry represents a file in a rcc archive. + */ +class KARCHIVE_EXPORT KRccFileEntry : public KArchiveFile +{ +public: + KRccFileEntry(KArchive *archive, const QString &name, int access, const QDateTime &date, + const QString &user, const QString &group, qint64 size, const QString &resourcePath) + : KArchiveFile(archive, name, access, date, user, group, QString(), 0, size), + m_resourcePath(resourcePath) + {} + + virtual QByteArray data() const Q_DECL_OVERRIDE + { + QFile f(m_resourcePath); + if (f.open(QIODevice::ReadOnly)) { + return f.readAll(); + } + qWarning() << "Couldn't open" << m_resourcePath; + return QByteArray(); + } + virtual QIODevice *createDevice() const Q_DECL_OVERRIDE + { + return new QFile(m_resourcePath); + } +private: + QString m_resourcePath; +}; + + +KRcc::KRcc(const QString &filename) + : KArchive(filename), d(new KRccPrivate) +{ +} + +KRcc::~KRcc() +{ + if (isOpen()) { + close(); + } + delete d; +} + +bool KRcc::doPrepareWriting(const QString &, const QString &, const QString &, + qint64, mode_t, const QDateTime &, const QDateTime &, const QDateTime &) +{ + return false; +} + +bool KRcc::doFinishWriting(qint64) +{ + return false; +} + +bool KRcc::doWriteDir(const QString &, const QString &, const QString &, + mode_t, const QDateTime &, const QDateTime &, const QDateTime &) +{ + return false; +} + +bool KRcc::doWriteSymLink(const QString &, const QString &, const QString &, + const QString &, mode_t, const QDateTime &, const QDateTime &, const QDateTime &) +{ + return false; +} + +bool KRcc::openArchive(QIODevice::OpenMode mode) +{ + // Open archive + + if (mode == QIODevice::WriteOnly) { + return true; + } + if (mode != QIODevice::ReadOnly && mode != QIODevice::ReadWrite) { + //qWarning() << "Unsupported mode " << mode; + return false; + } + + QUuid uuid = QUuid::createUuid(); + d->m_prefix = QLatin1Char('/') + uuid.toString(); + if (!QResource::registerResource(fileName(), d->m_prefix)) { + return false; + } + + QDir dir(QLatin1Char(':') + d->m_prefix); + d->createEntries(dir, rootDir(), this); + return true; +} + +void KRcc::KRccPrivate::createEntries(const QDir &dir, KArchiveDirectory *parentDir, KRcc* q) +{ + Q_FOREACH(const QString &fileName, dir.entryList()) { + const QString entryPath = dir.path() + QLatin1Char('/') + fileName; + const QFileInfo info(entryPath); + if (info.isFile()) { + KArchiveEntry *entry = new KRccFileEntry(q, fileName, 0444, info.lastModified(), + parentDir->user(), parentDir->group(), info.size(), entryPath); + parentDir->addEntry(entry); + } else { + KArchiveDirectory *entry = new KArchiveDirectory(q, fileName, 0555, info.lastModified(), + parentDir->user(), parentDir->group(), /*symlink*/ QString()); + parentDir->addEntry(entry); + createEntries(QDir(entryPath), entry, q); + } + } +} + +bool KRcc::closeArchive() +{ + // Close the archive + QResource::unregisterResource(fileName(), d->m_prefix); + // ignore errors + return true; +} + +void KRcc::virtual_hook(int id, void *data) +{ + KArchive::virtual_hook(id, data); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/krcc.h new/karchive-5.4.0/src/krcc.h --- old/karchive-5.3.0/src/krcc.h 1970-01-01 01:00:00.000000000 +0100 +++ new/karchive-5.4.0/src/krcc.h 2014-10-31 21:15:18.000000000 +0100 @@ -0,0 +1,96 @@ +/* This file is part of the KDE libraries + Copyright (C) 2014 David Faure <[email protected]> + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2 of the License or + ( at your option ) version 3 or, at the discretion of KDE e.V. + ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef KRCC_H +#define KRCC_H + +#include <karchive.h> + +/** + * KRcc is a class for reading dynamic binary resources created by Qt's rcc tool + * from a .qrc file and the files it points to. + * + * Writing is not supported. + * @short A class for reading rcc resources. + * @since 5.3 + */ +class KARCHIVE_EXPORT KRcc : public KArchive +{ +public: + /** + * Creates an instance that operates on the given filename. + * + * @param filename is a local path (e.g. "/home/holger/myfile.rcc") + */ + KRcc(const QString &filename); + + /** + * If the rcc file is still opened, then it will be + * closed automatically by the destructor. + */ + virtual ~KRcc(); + +protected: + + /* + * Writing is not supported by this class, will always fail. + * @return always false + */ + bool doPrepareWriting(const QString &name, const QString &user, const QString &group, qint64 size, + mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime) Q_DECL_OVERRIDE; + + /* + * Writing is not supported by this class, will always fail. + * @return always false + */ + bool doFinishWriting(qint64 size) Q_DECL_OVERRIDE; + + /* + * Writing is not supported by this class, will always fail. + * @return always false + */ + bool doWriteDir(const QString &name, const QString &user, const QString &group, + mode_t perm, const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime) Q_DECL_OVERRIDE; + + /* + * Writing is not supported by this class, will always fail. + * @return always false + */ + bool doWriteSymLink(const QString &name, const QString &target, + const QString &user, const QString &group, mode_t perm, + const QDateTime &atime, const QDateTime &mtime, const QDateTime &ctime) Q_DECL_OVERRIDE; + + /** + * Registers the .rcc resource in the QResource system under a unique identifier, + * then lists that, and creates the KArchiveFile/KArchiveDirectory entries. + */ + bool openArchive(QIODevice::OpenMode mode) Q_DECL_OVERRIDE; + /** + * Unregisters the .rcc resource from the QResource system. + */ + bool closeArchive() Q_DECL_OVERRIDE; + +protected: + void virtual_hook(int id, void *data) Q_DECL_OVERRIDE; +private: + class KRccPrivate; + KRccPrivate *const d; +}; + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/src/kxzfilter.h new/karchive-5.4.0/src/kxzfilter.h --- old/karchive-5.3.0/src/kxzfilter.h 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/src/kxzfilter.h 2014-10-31 21:15:18.000000000 +0100 @@ -39,7 +39,7 @@ KXzFilter(); virtual ~KXzFilter(); - virtual bool init(int); + bool init(int) Q_DECL_OVERRIDE; enum Flag { AUTO = 0, @@ -54,23 +54,23 @@ }; virtual bool init(int, Flag flag, const QVector<unsigned char> &props); - virtual int mode() const; - virtual bool terminate(); - virtual void reset(); - virtual bool readHeader() + int mode() const Q_DECL_OVERRIDE; + bool terminate() Q_DECL_OVERRIDE; + void reset() Q_DECL_OVERRIDE; + bool readHeader() Q_DECL_OVERRIDE { return true; // lzma handles it by itself ! Cool ! } - virtual bool writeHeader(const QByteArray &) + bool writeHeader(const QByteArray &) Q_DECL_OVERRIDE { return true; } - virtual void setOutBuffer(char *data, uint maxlen); - virtual void setInBuffer(const char *data, uint size); - virtual int inBufferAvailable() const; - virtual int outBufferAvailable() const; - virtual Result uncompress(); - virtual Result compress(bool finish); + void setOutBuffer(char *data, uint maxlen) Q_DECL_OVERRIDE; + void setInBuffer(const char *data, uint size) Q_DECL_OVERRIDE; + int inBufferAvailable() const Q_DECL_OVERRIDE; + int outBufferAvailable() const Q_DECL_OVERRIDE; + Result uncompress() Q_DECL_OVERRIDE; + Result compress(bool finish) Q_DECL_OVERRIDE; private: class Private; Private *const d; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/tests/CMakeLists.txt new/karchive-5.4.0/tests/CMakeLists.txt --- old/karchive-5.3.0/tests/CMakeLists.txt 2014-10-03 19:53:24.000000000 +0200 +++ new/karchive-5.4.0/tests/CMakeLists.txt 2014-10-31 21:15:18.000000000 +0100 @@ -12,6 +12,7 @@ karchive_executable_tests( ktartest + krcctest kziptest ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/karchive-5.3.0/tests/krcctest.cpp new/karchive-5.4.0/tests/krcctest.cpp --- old/karchive-5.3.0/tests/krcctest.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/karchive-5.4.0/tests/krcctest.cpp 2014-10-31 21:15:18.000000000 +0100 @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2002 - 2014 David Faure <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation; + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "krcc.h" +#include <stdio.h> +#include <QtCore/QDebug> + +void recursive_print(const KArchiveDirectory *dir, const QString &path) +{ + QStringList l = dir->entries(); + l.sort(); + QStringList::ConstIterator it = l.constBegin(); + for (; it != l.constEnd(); ++it) { + const KArchiveEntry *entry = dir->entry((*it)); + printf("mode=%07o %s %s %s%s %lld isdir=%d\n", entry->permissions(), entry->user().toLatin1().constData(), entry->group().toLatin1().constData(), path.toLatin1().constData(), (*it).toLatin1().constData(), + entry->isFile() ? static_cast<const KArchiveFile *>(entry)->size() : 0, + entry->isDirectory()); + if (!entry->symLinkTarget().isEmpty()) { + printf(" (symlink to %s)\n", qPrintable(entry->symLinkTarget())); + } + if (entry->isDirectory()) { + recursive_print((KArchiveDirectory *)entry, path + (*it) + '/'); + } + } +} + +// See karchivetest.cpp for the unittest that covers KTar. + +int main(int argc, char **argv) +{ + if (argc != 2) { + printf("\n" + " Usage :\n" + " ./ktartest /path/to/existing_file.tar.gz tests listing an existing tar.gz\n"); + return 1; + } + + KRcc rcc(argv[1]); + + if (!rcc.open(QIODevice::ReadOnly)) { + printf("Could not open %s for reading\n", argv[1]); + return 1; + } + + const KArchiveDirectory *dir = rcc.directory(); + + //printf("calling recursive_print\n"); + recursive_print(dir, ""); + //printf("recursive_print called\n"); + + rcc.close(); + + return 0; +} + -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
