QuaZIP quazip-0-6-2
quazipfile.h
00001 #ifndef QUA_ZIPFILE_H
00002 #define QUA_ZIPFILE_H
00003 
00004 /*
00005 Copyright (C) 2005-2014 Sergey A. Tachenov
00006 
00007 This file is part of QuaZIP.
00008 
00009 QuaZIP is free software: you can redistribute it and/or modify
00010 it under the terms of the GNU Lesser General Public License as published by
00011 the Free Software Foundation, either version 3 of the License, or
00012 (at your option) any later version.
00013 
00014 QuaZIP is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License
00020 along with QuaZIP.  If not, see <http://www.gnu.org/licenses/>.
00021 
00022 See COPYING file for the full LGPL text.
00023 
00024 Original ZIP package is copyrighted by Gilles Vollant, see
00025 quazip/(un)zip.h files for details, basically it's zlib license.
00026  **/
00027 
00028 #include <QIODevice>
00029 
00030 #include "quazip_global.h"
00031 #include "quazip.h"
00032 #include "quazipnewinfo.h"
00033 
00034 class QuaZipFilePrivate;
00035 
00037 
00074 class QUAZIP_EXPORT QuaZipFile: public QIODevice {
00075   friend class QuaZipFilePrivate;
00076   Q_OBJECT
00077   private:
00078     QuaZipFilePrivate *p;
00079     // these are not supported nor implemented
00080     QuaZipFile(const QuaZipFile& that);
00081     QuaZipFile& operator=(const QuaZipFile& that);
00082   protected:
00084     qint64 readData(char *data, qint64 maxSize);
00086     qint64 writeData(const char *data, qint64 maxSize);
00087   public:
00089 
00092     QuaZipFile();
00094 
00099     QuaZipFile(QObject *parent);
00101 
00110     QuaZipFile(const QString& zipName, QObject *parent =NULL);
00112 
00121     QuaZipFile(const QString& zipName, const QString& fileName,
00122         QuaZip::CaseSensitivity cs =QuaZip::csDefault, QObject *parent =NULL);
00124 
00172     QuaZipFile(QuaZip *zip, QObject *parent =NULL);
00174 
00177     virtual ~QuaZipFile();
00179 
00188     QString getZipName()const;
00190 
00193     QuaZip* getZip()const;
00195 
00207     QString getFileName() const;
00209 
00220     QuaZip::CaseSensitivity getCaseSensitivity() const;
00222 
00246     QString getActualFileName()const;
00248 
00254     void setZipName(const QString& zipName);
00256 
00260     bool isRaw() const;
00262 
00270     void setZip(QuaZip *zip);
00272 
00283     void setFileName(const QString& fileName, QuaZip::CaseSensitivity cs =QuaZip::csDefault);
00285 
00292     virtual bool open(OpenMode mode);
00294 
00298     inline bool open(OpenMode mode, const char *password)
00299     {return open(mode, NULL, NULL, false, password);}
00301 
00312     bool open(OpenMode mode, int *method, int *level, bool raw, const char *password =NULL);
00314 
00341     bool open(OpenMode mode, const QuaZipNewInfo& info,
00342         const char *password =NULL, quint32 crc =0,
00343         int method =Z_DEFLATED, int level =Z_DEFAULT_COMPRESSION, bool raw =false,
00344         int windowBits =-MAX_WBITS, int memLevel =DEF_MEM_LEVEL, int strategy =Z_DEFAULT_STRATEGY);
00346     virtual bool isSequential()const;
00348 
00369     virtual qint64 pos()const;
00371 
00387     virtual bool atEnd()const;
00389 
00401     virtual qint64 size()const;
00403 
00410     qint64 csize()const;
00412 
00420     qint64 usize()const;
00422 
00438     bool getFileInfo(QuaZipFileInfo *info);
00440 
00445     bool getFileInfo(QuaZipFileInfo64 *info);
00447 
00449     virtual void close();
00451     int getZipError() const;
00453     virtual qint64 bytesAvailable() const;
00454 };
00455 
00456 #endif