00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef OSDAB_UNZIP_P__H
00040 #define OSDAB_UNZIP_P__H
00041
00042 #include "unzip.h"
00043 #include "zipentry_p.h"
00044
00045 #include <QtGlobal>
00046
00047
00048
00049 #define UNZIP_READ_BUFFER (256*1024)
00050
00051 class UnzipPrivate
00052 {
00053 public:
00054 UnzipPrivate();
00055
00056
00057 QString password;
00058
00059 bool skipAllEncrypted;
00060
00061 QMap<QString,ZipEntryP*>* headers;
00062
00063 QIODevice* device;
00064
00065 char buffer1[UNZIP_READ_BUFFER];
00066 char buffer2[UNZIP_READ_BUFFER];
00067
00068 unsigned char* uBuffer;
00069 const quint32* crcTable;
00070
00071
00072 quint32 cdOffset;
00073
00074 quint32 eocdOffset;
00075
00076
00077 quint16 cdEntryCount;
00078
00079
00080 quint16 unsupportedEntryCount;
00081
00082 QString comment;
00083
00084 UnZip::ErrorCode openArchive(QIODevice* device);
00085
00086 UnZip::ErrorCode seekToCentralDirectory();
00087 UnZip::ErrorCode parseCentralDirectoryRecord();
00088 UnZip::ErrorCode parseLocalHeaderRecord(const QString& path, ZipEntryP& entry);
00089
00090 void closeArchive();
00091
00092 UnZip::ErrorCode extractFile(const QString& path, ZipEntryP& entry, const QDir& dir, UnZip::ExtractionOptions options);
00093 UnZip::ErrorCode extractFile(const QString& path, ZipEntryP& entry, QIODevice* device, UnZip::ExtractionOptions options);
00094
00095 UnZip::ErrorCode testPassword(quint32* keys, const QString& file, const ZipEntryP& header);
00096 bool testKeys(const ZipEntryP& header, quint32* keys);
00097
00098 bool createDirectory(const QString& path);
00099
00100 inline void decryptBytes(quint32* keys, char* buffer, qint64 read);
00101
00102 inline quint32 getULong(const unsigned char* data, quint32 offset) const;
00103 inline quint64 getULLong(const unsigned char* data, quint32 offset) const;
00104 inline quint16 getUShort(const unsigned char* data, quint32 offset) const;
00105 inline int decryptByte(quint32 key2) const;
00106 inline void updateKeys(quint32* keys, int c) const;
00107 inline void initKeys(const QString& pwd, quint32* keys) const;
00108
00109 inline QDateTime convertDateTime(const unsigned char date[2], const unsigned char time[2]) const;
00110 };
00111
00112 #endif // OSDAB_UNZIP_P__H