misc/quazip/quazipfile.h
author unc0rr
Tue, 13 Nov 2012 23:16:21 +0400
branchphysfslayer
changeset 7971 fcbaa236a2d5
parent 7889 57b117d441b9
permissions -rw-r--r--
dos2unix hedgewars.pro
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7889
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
     1
#ifndef QUA_ZIPFILE_H
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
     2
#define QUA_ZIPFILE_H
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
     3
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
     4
/*
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
     5
Copyright (C) 2005-2011 Sergey A. Tachenov
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
     6
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
     7
This program is free software; you can redistribute it and/or modify it
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
     8
under the terms of the GNU Lesser General Public License as published by
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
     9
the Free Software Foundation; either version 2 of the License, or (at
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    10
your option) any later version.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    11
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    12
This program is distributed in the hope that it will be useful, but
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    13
WITHOUT ANY WARRANTY; without even the implied warranty of
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    15
General Public License for more details.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    16
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    17
You should have received a copy of the GNU Lesser General Public License
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    18
along with this program; if not, write to the Free Software Foundation,
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    19
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    20
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    21
See COPYING file for the full LGPL text.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    22
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    23
Original ZIP package is copyrighted by Gilles Vollant, see
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    24
quazip/(un)zip.h files for details, basically it's zlib license.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    25
 **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    26
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    27
#include <QIODevice>
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    28
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    29
#include "quazip_global.h"
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    30
#include "quazip.h"
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    31
#include "quazipnewinfo.h"
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    32
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    33
class QuaZipFilePrivate;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    34
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    35
/// A file inside ZIP archive.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    36
/** \class QuaZipFile quazipfile.h <quazip/quazipfile.h>
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    37
 * This is the most interesting class. Not only it provides C++
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    38
 * interface to the ZIP/UNZIP package, but also integrates it with Qt by
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    39
 * subclassing QIODevice. This makes possible to access files inside ZIP
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    40
 * archive using QTextStream or QDataStream, for example. Actually, this
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    41
 * is the main purpose of the whole QuaZIP library.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    42
 *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    43
 * You can either use existing QuaZip instance to create instance of
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    44
 * this class or pass ZIP archive file name to this class, in which case
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    45
 * it will create internal QuaZip object. See constructors' descriptions
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    46
 * for details. Writing is only possible with the existing instance.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    47
 *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    48
 * Note that due to the underlying library's limitation it is not
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    49
 * possible to use multiple QuaZipFile instances to open several files
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    50
 * in the same archive at the same time. If you need to write to
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    51
 * multiple files in parallel, then you should write to temporary files
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    52
 * first, then pack them all at once when you have finished writing. If
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    53
 * you need to read multiple files inside the same archive in parallel,
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    54
 * you should extract them all into a temporary directory first.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    55
 *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    56
 * \section quazipfile-sequential Sequential or random-access?
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    57
 *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    58
 * At the first thought, QuaZipFile has fixed size, the start and the
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    59
 * end and should be therefore considered random-access device. But
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    60
 * there is one major obstacle to making it random-access: ZIP/UNZIP API
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    61
 * does not support seek() operation and the only way to implement it is
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    62
 * through reopening the file and re-reading to the required position,
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    63
 * but this is prohibitively slow.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    64
 *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    65
 * Therefore, QuaZipFile is considered to be a sequential device. This
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    66
 * has advantage of availability of the ungetChar() operation (QIODevice
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    67
 * does not implement it properly for non-sequential devices unless they
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    68
 * support seek()). Disadvantage is a somewhat strange behaviour of the
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    69
 * size() and pos() functions. This should be kept in mind while using
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    70
 * this class.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    71
 *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    72
 **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    73
class QUAZIP_EXPORT QuaZipFile: public QIODevice {
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    74
  friend class QuaZipFilePrivate;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    75
  Q_OBJECT
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    76
  private:
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    77
    QuaZipFilePrivate *p;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    78
    // these are not supported nor implemented
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    79
    QuaZipFile(const QuaZipFile& that);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    80
    QuaZipFile& operator=(const QuaZipFile& that);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    81
  protected:
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    82
    /// Implementation of the QIODevice::readData().
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    83
    qint64 readData(char *data, qint64 maxSize);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    84
    /// Implementation of the QIODevice::writeData().
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    85
    qint64 writeData(const char *data, qint64 maxSize);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    86
  public:
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    87
    /// Constructs a QuaZipFile instance.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    88
    /** You should use setZipName() and setFileName() or setZip() before
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    89
     * trying to call open() on the constructed object.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    90
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    91
    QuaZipFile();
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    92
    /// Constructs a QuaZipFile instance.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    93
    /** \a parent argument specifies this object's parent object.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    94
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    95
     * You should use setZipName() and setFileName() or setZip() before
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    96
     * trying to call open() on the constructed object.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    97
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    98
    QuaZipFile(QObject *parent);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
    99
    /// Constructs a QuaZipFile instance.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   100
    /** \a parent argument specifies this object's parent object and \a
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   101
     * zipName specifies ZIP archive file name.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   102
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   103
     * You should use setFileName() before trying to call open() on the
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   104
     * constructed object.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   105
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   106
     * QuaZipFile constructed by this constructor can be used for read
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   107
     * only access. Use QuaZipFile(QuaZip*,QObject*) for writing.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   108
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   109
    QuaZipFile(const QString& zipName, QObject *parent =NULL);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   110
    /// Constructs a QuaZipFile instance.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   111
    /** \a parent argument specifies this object's parent object, \a
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   112
     * zipName specifies ZIP archive file name and \a fileName and \a cs
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   113
     * specify a name of the file to open inside archive.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   114
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   115
     * QuaZipFile constructed by this constructor can be used for read
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   116
     * only access. Use QuaZipFile(QuaZip*,QObject*) for writing.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   117
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   118
     * \sa QuaZip::setCurrentFile()
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   119
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   120
    QuaZipFile(const QString& zipName, const QString& fileName,
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   121
        QuaZip::CaseSensitivity cs =QuaZip::csDefault, QObject *parent =NULL);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   122
    /// Constructs a QuaZipFile instance.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   123
    /** \a parent argument specifies this object's parent object.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   124
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   125
     * \a zip is the pointer to the existing QuaZip object. This
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   126
     * QuaZipFile object then can be used to read current file in the
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   127
     * \a zip or to write to the file inside it.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   128
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   129
     * \warning Using this constructor for reading current file can be
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   130
     * tricky. Let's take the following example:
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   131
     * \code
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   132
     * QuaZip zip("archive.zip");
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   133
     * zip.open(QuaZip::mdUnzip);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   134
     * zip.setCurrentFile("file-in-archive");
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   135
     * QuaZipFile file(&zip);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   136
     * file.open(QIODevice::ReadOnly);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   137
     * // ok, now we can read from the file
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   138
     * file.read(somewhere, some);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   139
     * zip.setCurrentFile("another-file-in-archive"); // oops...
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   140
     * QuaZipFile anotherFile(&zip);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   141
     * anotherFile.open(QIODevice::ReadOnly);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   142
     * anotherFile.read(somewhere, some); // this is still ok...
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   143
     * file.read(somewhere, some); // and this is NOT
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   144
     * \endcode
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   145
     * So, what exactly happens here? When we change current file in the
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   146
     * \c zip archive, \c file that references it becomes invalid
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   147
     * (actually, as far as I understand ZIP/UNZIP sources, it becomes
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   148
     * closed, but QuaZipFile has no means to detect it).
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   149
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   150
     * Summary: do not close \c zip object or change its current file as
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   151
     * long as QuaZipFile is open. Even better - use another constructors
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   152
     * which create internal QuaZip instances, one per object, and
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   153
     * therefore do not cause unnecessary trouble. This constructor may
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   154
     * be useful, though, if you already have a QuaZip instance and do
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   155
     * not want to access several files at once. Good example:
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   156
     * \code
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   157
     * QuaZip zip("archive.zip");
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   158
     * zip.open(QuaZip::mdUnzip);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   159
     * // first, we need some information about archive itself
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   160
     * QByteArray comment=zip.getComment();
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   161
     * // and now we are going to access files inside it
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   162
     * QuaZipFile file(&zip);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   163
     * for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile()) {
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   164
     *   file.open(QIODevice::ReadOnly);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   165
     *   // do something cool with file here
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   166
     *   file.close(); // do not forget to close!
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   167
     * }
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   168
     * zip.close();
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   169
     * \endcode
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   170
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   171
    QuaZipFile(QuaZip *zip, QObject *parent =NULL);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   172
    /// Destroys a QuaZipFile instance.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   173
    /** Closes file if open, destructs internal QuaZip object (if it
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   174
     * exists and \em is internal, of course).
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   175
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   176
    virtual ~QuaZipFile();
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   177
    /// Returns the ZIP archive file name.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   178
    /** If this object was created by passing QuaZip pointer to the
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   179
     * constructor, this function will return that QuaZip's file name
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   180
     * (or null string if that object does not have file name yet).
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   181
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   182
     * Otherwise, returns associated ZIP archive file name or null
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   183
     * string if there are no name set yet.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   184
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   185
     * \sa setZipName() getFileName()
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   186
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   187
    QString getZipName()const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   188
    /// Returns a pointer to the associated QuaZip object.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   189
    /** Returns \c NULL if there is no associated QuaZip or it is
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   190
     * internal (so you will not mess with it).
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   191
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   192
    QuaZip* getZip()const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   193
    /// Returns file name.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   194
    /** This function returns file name you passed to this object either
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   195
     * by using
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   196
     * QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*)
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   197
     * or by calling setFileName(). Real name of the file may differ in
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   198
     * case if you used case-insensitivity.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   199
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   200
     * Returns null string if there is no file name set yet. This is the
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   201
     * case when this QuaZipFile operates on the existing QuaZip object
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   202
     * (constructor QuaZipFile(QuaZip*,QObject*) or setZip() was used).
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   203
     * 
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   204
     * \sa getActualFileName
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   205
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   206
    QString getFileName() const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   207
    /// Returns case sensitivity of the file name.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   208
    /** This function returns case sensitivity argument you passed to
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   209
     * this object either by using
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   210
     * QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*)
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   211
     * or by calling setFileName().
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   212
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   213
     * Returns unpredictable value if getFileName() returns null string
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   214
     * (this is the case when you did not used setFileName() or
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   215
     * constructor above).
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   216
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   217
     * \sa getFileName
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   218
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   219
    QuaZip::CaseSensitivity getCaseSensitivity() const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   220
    /// Returns the actual file name in the archive.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   221
    /** This is \em not a ZIP archive file name, but a name of file inside
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   222
     * archive. It is not necessary the same name that you have passed
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   223
     * to the
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   224
     * QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*),
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   225
     * setFileName() or QuaZip::setCurrentFile() - this is the real file
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   226
     * name inside archive, so it may differ in case if the file name
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   227
     * search was case-insensitive.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   228
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   229
     * Equivalent to calling getCurrentFileName() on the associated
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   230
     * QuaZip object. Returns null string if there is no associated
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   231
     * QuaZip object or if it does not have a current file yet. And this
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   232
     * is the case if you called setFileName() but did not open the
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   233
     * file yet. So this is perfectly fine:
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   234
     * \code
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   235
     * QuaZipFile file("somezip.zip");
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   236
     * file.setFileName("somefile");
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   237
     * QString name=file.getName(); // name=="somefile"
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   238
     * QString actual=file.getActualFileName(); // actual is null string
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   239
     * file.open(QIODevice::ReadOnly);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   240
     * QString actual=file.getActualFileName(); // actual can be "SoMeFiLe" on Windows
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   241
     * \endcode
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   242
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   243
     * \sa getZipName(), getFileName(), QuaZip::CaseSensitivity
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   244
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   245
    QString getActualFileName()const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   246
    /// Sets the ZIP archive file name.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   247
    /** Automatically creates internal QuaZip object and destroys
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   248
     * previously created internal QuaZip object, if any.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   249
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   250
     * Will do nothing if this file is already open. You must close() it
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   251
     * first.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   252
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   253
    void setZipName(const QString& zipName);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   254
    /// Returns \c true if the file was opened in raw mode.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   255
    /** If the file is not open, the returned value is undefined.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   256
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   257
     * \sa open(OpenMode,int*,int*,bool,const char*)
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   258
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   259
    bool isRaw() const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   260
    /// Binds to the existing QuaZip instance.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   261
    /** This function destroys internal QuaZip object, if any, and makes
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   262
     * this QuaZipFile to use current file in the \a zip object for any
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   263
     * further operations. See QuaZipFile(QuaZip*,QObject*) for the
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   264
     * possible pitfalls.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   265
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   266
     * Will do nothing if the file is currently open. You must close()
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   267
     * it first.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   268
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   269
    void setZip(QuaZip *zip);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   270
    /// Sets the file name.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   271
    /** Will do nothing if at least one of the following conditions is
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   272
     * met:
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   273
     * - ZIP name has not been set yet (getZipName() returns null
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   274
     *   string).
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   275
     * - This QuaZipFile is associated with external QuaZip. In this
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   276
     *   case you should call that QuaZip's setCurrentFile() function
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   277
     *   instead!
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   278
     * - File is already open so setting the name is meaningless.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   279
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   280
     * \sa QuaZip::setCurrentFile
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   281
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   282
    void setFileName(const QString& fileName, QuaZip::CaseSensitivity cs =QuaZip::csDefault);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   283
    /// Opens a file for reading.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   284
    /** Returns \c true on success, \c false otherwise.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   285
     * Call getZipError() to get error code.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   286
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   287
     * \note Since ZIP/UNZIP API provides buffered reading only,
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   288
     * QuaZipFile does not support unbuffered reading. So do not pass
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   289
     * QIODevice::Unbuffered flag in \a mode, or open will fail.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   290
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   291
    virtual bool open(OpenMode mode);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   292
    /// Opens a file for reading.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   293
    /** \overload
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   294
     * Argument \a password specifies a password to decrypt the file. If
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   295
     * it is NULL then this function behaves just like open(OpenMode).
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   296
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   297
    inline bool open(OpenMode mode, const char *password)
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   298
    {return open(mode, NULL, NULL, false, password);}
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   299
    /// Opens a file for reading.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   300
    /** \overload
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   301
     * Argument \a password specifies a password to decrypt the file.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   302
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   303
     * An integers pointed by \a method and \a level will receive codes
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   304
     * of the compression method and level used. See unzip.h.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   305
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   306
     * If raw is \c true then no decompression is performed.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   307
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   308
     * \a method should not be \c NULL. \a level can be \c NULL if you
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   309
     * don't want to know the compression level.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   310
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   311
    bool open(OpenMode mode, int *method, int *level, bool raw, const char *password =NULL);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   312
    /// Opens a file for writing.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   313
    /** \a info argument specifies information about file. It should at
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   314
     * least specify a correct file name. Also, it is a good idea to
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   315
     * specify correct timestamp (by default, current time will be
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   316
     * used). See QuaZipNewInfo.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   317
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   318
     * Arguments \a password and \a crc provide necessary information
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   319
     * for crypting. Note that you should specify both of them if you
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   320
     * need crypting. If you do not, pass \c NULL as password, but you
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   321
     * still need to specify \a crc if you are going to use raw mode
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   322
     * (see below).
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   323
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   324
     * Arguments \a method and \a level specify compression method and
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   325
     * level.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   326
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   327
     * If \a raw is \c true, no compression is performed. In this case,
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   328
     * \a crc and uncompressedSize field of the \a info are required.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   329
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   330
     * Arguments \a windowBits, \a memLevel, \a strategy provide zlib
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   331
     * algorithms tuning. See deflateInit2() in zlib.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   332
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   333
    bool open(OpenMode mode, const QuaZipNewInfo& info,
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   334
        const char *password =NULL, quint32 crc =0,
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   335
        int method =Z_DEFLATED, int level =Z_DEFAULT_COMPRESSION, bool raw =false,
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   336
        int windowBits =-MAX_WBITS, int memLevel =DEF_MEM_LEVEL, int strategy =Z_DEFAULT_STRATEGY);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   337
    /// Returns \c true, but \ref quazipfile-sequential "beware"!
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   338
    virtual bool isSequential()const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   339
    /// Returns current position in the file.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   340
    /** Implementation of the QIODevice::pos(). When reading, this
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   341
     * function is a wrapper to the ZIP/UNZIP unztell(), therefore it is
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   342
     * unable to keep track of the ungetChar() calls (which is
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   343
     * non-virtual and therefore is dangerous to reimplement). So if you
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   344
     * are using ungetChar() feature of the QIODevice, this function
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   345
     * reports incorrect value until you get back characters which you
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   346
     * ungot.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   347
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   348
     * When writing, pos() returns number of bytes already written
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   349
     * (uncompressed unless you use raw mode).
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   350
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   351
     * \note Although
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   352
     * \ref quazipfile-sequential "QuaZipFile is a sequential device"
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   353
     * and therefore pos() should always return zero, it does not,
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   354
     * because it would be misguiding. Keep this in mind.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   355
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   356
     * This function returns -1 if the file or archive is not open.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   357
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   358
     * Error code returned by getZipError() is not affected by this
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   359
     * function call.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   360
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   361
    virtual qint64 pos()const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   362
    /// Returns \c true if the end of file was reached.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   363
    /** This function returns \c false in the case of error. This means
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   364
     * that you called this function on either not open file, or a file
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   365
     * in the not open archive or even on a QuaZipFile instance that
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   366
     * does not even have QuaZip instance associated. Do not do that
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   367
     * because there is no means to determine whether \c false is
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   368
     * returned because of error or because end of file was reached.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   369
     * Well, on the other side you may interpret \c false return value
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   370
     * as "there is no file open to check for end of file and there is
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   371
     * no end of file therefore".
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   372
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   373
     * When writing, this function always returns \c true (because you
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   374
     * are always writing to the end of file).
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   375
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   376
     * Error code returned by getZipError() is not affected by this
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   377
     * function call.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   378
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   379
    virtual bool atEnd()const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   380
    /// Returns file size.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   381
    /** This function returns csize() if the file is open for reading in
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   382
     * raw mode, usize() if it is open for reading in normal mode and
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   383
     * pos() if it is open for writing.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   384
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   385
     * Returns -1 on error, call getZipError() to get error code.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   386
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   387
     * \note This function returns file size despite that
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   388
     * \ref quazipfile-sequential "QuaZipFile is considered to be sequential device",
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   389
     * for which size() should return bytesAvailable() instead. But its
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   390
     * name would be very misguiding otherwise, so just keep in mind
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   391
     * this inconsistence.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   392
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   393
    virtual qint64 size()const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   394
    /// Returns compressed file size.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   395
    /** Equivalent to calling getFileInfo() and then getting
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   396
     * compressedSize field, but more convenient and faster.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   397
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   398
     * File must be open for reading before calling this function.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   399
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   400
     * Returns -1 on error, call getZipError() to get error code.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   401
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   402
    qint64 csize()const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   403
    /// Returns uncompressed file size.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   404
    /** Equivalent to calling getFileInfo() and then getting
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   405
     * uncompressedSize field, but more convenient and faster. See
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   406
     * getFileInfo() for a warning.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   407
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   408
     * File must be open for reading before calling this function.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   409
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   410
     * Returns -1 on error, call getZipError() to get error code.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   411
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   412
    qint64 usize()const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   413
    /// Gets information about current file.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   414
    /** This function does the same thing as calling
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   415
     * QuaZip::getCurrentFileInfo() on the associated QuaZip object,
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   416
     * but you can not call getCurrentFileInfo() if the associated
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   417
     * QuaZip is internal (because you do not have access to it), while
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   418
     * you still can call this function in that case.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   419
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   420
     * File must be open for reading before calling this function.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   421
     *
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   422
     * Returns \c false in the case of an error.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   423
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   424
    bool getFileInfo(QuaZipFileInfo *info);
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   425
    /// Closes the file.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   426
    /** Call getZipError() to determine if the close was successful.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   427
     **/
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   428
    virtual void close();
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   429
    /// Returns the error code returned by the last ZIP/UNZIP API call.
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   430
    int getZipError() const;
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   431
};
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   432
57b117d441b9 consistent line endings
nemo
parents: 5752
diff changeset
   433
#endif