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