summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/zip/unzip_p.h
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2007-07-25 20:21:06 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2007-07-25 20:21:06 +0000
commit680408f4ac8b04d716fd8921c01b73d30a3c66c7 (patch)
tree08908a7d5e3b95daa9a1d3ed0703e64cff712022 /rbutil/rbutilqt/zip/unzip_p.h
parentaa643db434e230643e18e454032fb708e0f1848d (diff)
downloadrockbox-680408f4ac8b04d716fd8921c01b73d30a3c66c7.tar.gz
rockbox-680408f4ac8b04d716fd8921c01b73d30a3c66c7.zip
First stab at porting rbutil to Qt4. Currently only installing a current or archived build is working. To build, run qmake && make in the source folder. Beware that the syntax of rbutil.ini has slightly changed. Caching of the downloaded files is also still missing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13989 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/zip/unzip_p.h')
-rw-r--r--rbutil/rbutilqt/zip/unzip_p.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/zip/unzip_p.h b/rbutil/rbutilqt/zip/unzip_p.h
new file mode 100644
index 0000000000..c05ac67b47
--- /dev/null
+++ b/rbutil/rbutilqt/zip/unzip_p.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+** Filename: unzip_p.h
+** Last updated [dd/mm/yyyy]: 28/01/2007
+**
+** pkzip 2.0 decompression.
+**
+** Some of the code has been inspired by other open source projects,
+** (mainly Info-Zip and Gilles Vollant's minizip).
+** Compression and decompression actually uses the zlib library.
+**
+** Copyright (C) 2007 Angius Fabrizio. All rights reserved.
+**
+** This file is part of the OSDaB project (http://osdab.sourceforge.net/).
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See the file LICENSE.GPL that came with this software distribution or
+** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
+**
+**********************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Zip/UnZip API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef OSDAB_UNZIP_P__H
+#define OSDAB_UNZIP_P__H
+
+#include "unzip.h"
+#include "zipentry_p.h"
+
+#include <QtGlobal>
+
+// zLib authors suggest using larger buffers (128K or 256K) for (de)compression (especially for inflate())
+// we use a 256K buffer here - if you want to use this code on a pre-iceage mainframe please change it ;)
+#define UNZIP_READ_BUFFER (256*1024)
+
+class UnzipPrivate
+{
+public:
+ UnzipPrivate();
+
+ // Replace this with whatever else you use to store/retrieve the password.
+ QString password;
+
+ bool skipAllEncrypted;
+
+ QMap<QString,ZipEntryP*>* headers;
+
+ QIODevice* device;
+
+ char buffer1[UNZIP_READ_BUFFER];
+ char buffer2[UNZIP_READ_BUFFER];
+
+ unsigned char* uBuffer;
+ const quint32* crcTable;
+
+ // Central Directory (CD) offset
+ quint32 cdOffset;
+ // End of Central Directory (EOCD) offset
+ quint32 eocdOffset;
+
+ // Number of entries in the Central Directory (as to the EOCD record)
+ quint16 cdEntryCount;
+
+ // The number of detected entries that have been skipped because of a non compatible format
+ quint16 unsupportedEntryCount;
+
+ QString comment;
+
+ UnZip::ErrorCode openArchive(QIODevice* device);
+
+ UnZip::ErrorCode seekToCentralDirectory();
+ UnZip::ErrorCode parseCentralDirectoryRecord();
+ UnZip::ErrorCode parseLocalHeaderRecord(const QString& path, ZipEntryP& entry);
+
+ void closeArchive();
+
+ UnZip::ErrorCode extractFile(const QString& path, ZipEntryP& entry, const QDir& dir, UnZip::ExtractionOptions options);
+ UnZip::ErrorCode extractFile(const QString& path, ZipEntryP& entry, QIODevice* device, UnZip::ExtractionOptions options);
+
+ UnZip::ErrorCode testPassword(quint32* keys, const QString& file, const ZipEntryP& header);
+ bool testKeys(const ZipEntryP& header, quint32* keys);
+
+ bool createDirectory(const QString& path);
+
+ inline void decryptBytes(quint32* keys, char* buffer, qint64 read);
+
+ inline quint32 getULong(const unsigned char* data, quint32 offset) const;
+ inline quint64 getULLong(const unsigned char* data, quint32 offset) const;
+ inline quint16 getUShort(const unsigned char* data, quint32 offset) const;
+ inline int decryptByte(quint32 key2) const;
+ inline void updateKeys(quint32* keys, int c) const;
+ inline void initKeys(const QString& pwd, quint32* keys) const;
+
+ inline QDateTime convertDateTime(const unsigned char date[2], const unsigned char time[2]) const;
+};
+
+#endif // OSDAB_UNZIP_P__H