zip_p.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Filename: zip_p.h
00003 ** Last updated [dd/mm/yyyy]: 28/01/2007
00004 **
00005 ** pkzip 2.0 file compression.
00006 **
00007 ** Some of the code has been inspired by other open source projects,
00008 ** (mainly Info-Zip and Gilles Vollant's minizip).
00009 ** Compression and decompression actually uses the zlib library.
00010 **
00011 ** Copyright (C) 2007 Angius Fabrizio. All rights reserved.
00012 **
00013 ** This file is part of the OSDaB project (http://osdab.sourceforge.net/).
00014 **
00015 ** This file may be distributed and/or modified under the terms of the
00016 ** GNU General Public License version 2 as published by the Free Software
00017 ** Foundation and appearing in the file LICENSE.GPL included in the
00018 ** packaging of this file.
00019 **
00020 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00021 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00022 **
00023 ** See the file LICENSE.GPL that came with this software distribution or
00024 ** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
00025 **
00026 **********************************************************************/
00027 
00028 //
00029 //  W A R N I N G
00030 //  -------------
00031 //
00032 // This file is not part of the Zip/UnZip API.  It exists purely as an
00033 // implementation detail. This header file may change from version to
00034 // version without notice, or even be removed.
00035 //
00036 // We mean it.
00037 //
00038 
00039 #ifndef OSDAB_ZIP_P__H
00040 #define OSDAB_ZIP_P__H
00041 
00042 #include "zip.h"
00043 #include "zipentry_p.h"
00044 
00045 #include <QtGlobal>
00046 #include <QFileInfo>
00047 
00052 #define ZIP_READ_BUFFER (256*1024)
00053 
00054 class ZipPrivate
00055 {
00056 public:
00057     ZipPrivate();
00058     virtual ~ZipPrivate();
00059 
00060     QMap<QString,ZipEntryP*>* headers;
00061 
00062     QIODevice* device;
00063 
00064     char buffer1[ZIP_READ_BUFFER];
00065     char buffer2[ZIP_READ_BUFFER];
00066 
00067     unsigned char* uBuffer;
00068 
00069     const quint32* crcTable;
00070 
00071     QString comment;
00072     QString password;
00073 
00074     Zip::ErrorCode createArchive(QIODevice* device);
00075     Zip::ErrorCode closeArchive();
00076     void reset();
00077 
00078     bool zLibInit();
00079 
00080     Zip::ErrorCode createEntry(const QFileInfo& file, const QString& root, Zip::CompressionLevel level);
00081     Zip::CompressionLevel detectCompressionByMime(const QString& ext);
00082 
00083     inline void encryptBytes(quint32* keys, char* buffer, qint64 read);
00084 
00085     inline void setULong(quint32 v, char* buffer, unsigned int offset);
00086     inline void updateKeys(quint32* keys, int c) const;
00087     inline void initKeys(quint32* keys) const;
00088     inline int decryptByte(quint32 key2) const;
00089 
00090     inline QString extractRoot(const QString& p);
00091 };
00092 
00093 #endif // OSDAB_ZIP_P__H