Zip archives are now extracted with unzip utility instead of OSDaB-Zip.
[emufront] / src / utils / OSDaB-Zip / unzip_p.h
1 /****************************************************************************\r
2 ** Filename: unzip_p.h\r
3 ** Last updated [dd/mm/yyyy]: 28/01/2007\r
4 **\r
5 ** pkzip 2.0 decompression.\r
6 **\r
7 ** Some of the code has been inspired by other open source projects,\r
8 ** (mainly Info-Zip and Gilles Vollant's minizip).\r
9 ** Compression and decompression actually uses the zlib library.\r
10 **\r
11 ** Copyright (C) 2007-2008 Angius Fabrizio. All rights reserved.\r
12 **\r
13 ** This file is part of the OSDaB project (http://osdab.sourceforge.net/).\r
14 **\r
15 ** This file may be distributed and/or modified under the terms of the\r
16 ** GNU General Public License version 2 as published by the Free Software\r
17 ** Foundation and appearing in the file LICENSE.GPL included in the\r
18 ** packaging of this file.\r
19 **\r
20 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE\r
21 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\r
22 **\r
23 ** See the file LICENSE.GPL that came with this software distribution or\r
24 ** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.\r
25 **\r
26 **********************************************************************/\r
27 \r
28 //\r
29 //  W A R N I N G\r
30 //  -------------\r
31 //\r
32 // This file is not part of the Zip/UnZip API.  It exists purely as an\r
33 // implementation detail. This header file may change from version to\r
34 // version without notice, or even be removed.\r
35 //\r
36 // We mean it.\r
37 //\r
38 \r
39 #ifndef OSDAB_UNZIP_P__H\r
40 #define OSDAB_UNZIP_P__H\r
41 \r
42 #include "unzip.h"\r
43 #include "zipentry_p.h"\r
44 \r
45 #include <QtGlobal>\r
46 \r
47 // zLib authors suggest using larger buffers (128K or 256K) for (de)compression (especially for inflate())\r
48 // we use a 256K buffer here - if you want to use this code on a pre-iceage mainframe please change it ;)\r
49 #define UNZIP_READ_BUFFER (256*1024)\r
50 \r
51 class UnzipPrivate\r
52 {\r
53 public:\r
54         UnzipPrivate();\r
55 \r
56         // Replace this with whatever else you use to store/retrieve the password.\r
57         QString password;\r
58 \r
59         bool skipAllEncrypted;\r
60 \r
61         QMap<QString,ZipEntryP*>* headers;\r
62 \r
63         QIODevice* device;\r
64 \r
65         char buffer1[UNZIP_READ_BUFFER];\r
66         char buffer2[UNZIP_READ_BUFFER];\r
67 \r
68         unsigned char* uBuffer;\r
69         const quint32* crcTable;\r
70 \r
71         // Central Directory (CD) offset\r
72         quint32 cdOffset;\r
73         // End of Central Directory (EOCD) offset\r
74         quint32 eocdOffset;\r
75 \r
76         // Number of entries in the Central Directory (as to the EOCD record)\r
77         quint16 cdEntryCount;\r
78 \r
79         // The number of detected entries that have been skipped because of a non compatible format\r
80         quint16 unsupportedEntryCount;\r
81 \r
82         QString comment;\r
83 \r
84         UnZip::ErrorCode openArchive(QIODevice* device);\r
85 \r
86         UnZip::ErrorCode seekToCentralDirectory();\r
87         UnZip::ErrorCode parseCentralDirectoryRecord();\r
88         UnZip::ErrorCode parseLocalHeaderRecord(const QString& path, ZipEntryP& entry);\r
89 \r
90         void closeArchive();\r
91 \r
92         UnZip::ErrorCode extractFile(const QString& path, ZipEntryP& entry, const QDir& dir, UnZip::ExtractionOptions options);\r
93         UnZip::ErrorCode extractFile(const QString& path, ZipEntryP& entry, QIODevice* device, UnZip::ExtractionOptions options);\r
94 \r
95         UnZip::ErrorCode testPassword(quint32* keys, const QString& file, const ZipEntryP& header);\r
96         bool testKeys(const ZipEntryP& header, quint32* keys);\r
97 \r
98         bool createDirectory(const QString& path);\r
99 \r
100         inline void decryptBytes(quint32* keys, char* buffer, qint64 read);\r
101 \r
102         inline quint32 getULong(const unsigned char* data, quint32 offset) const;\r
103         inline quint64 getULLong(const unsigned char* data, quint32 offset) const;\r
104         inline quint16 getUShort(const unsigned char* data, quint32 offset) const;\r
105         inline int decryptByte(quint32 key2) const;\r
106         inline void updateKeys(quint32* keys, int c) const;\r
107         inline void initKeys(const QString& pwd, quint32* keys) const;\r
108 \r
109         inline QDateTime convertDateTime(const unsigned char date[2], const unsigned char time[2]) const;\r
110 };\r
111 \r
112 #endif // OSDAB_UNZIP_P__H\r