misc/quazip/quazip.cpp
author sheepluva
Sun, 11 Sep 2011 18:35:59 +0200
changeset 5859 285b3fd862e7
parent 5752 ea95ee97c805
child 7889 57b117d441b9
permissions -rw-r--r--
added some changes I remembered/saw in the logs to the changelog
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5752
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     1
/*
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     2
Copyright (C) 2005-2011 Sergey A. Tachenov
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     3
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     4
This program is free software; you can redistribute it and/or modify it
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     5
under the terms of the GNU Lesser General Public License as published by
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     6
the Free Software Foundation; either version 2 of the License, or (at
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     7
your option) any later version.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     8
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     9
This program is distributed in the hope that it will be useful, but
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    10
WITHOUT ANY WARRANTY; without even the implied warranty of
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    12
General Public License for more details.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    13
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    14
You should have received a copy of the GNU Lesser General Public License
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    15
along with this program; if not, write to the Free Software Foundation,
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    16
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    17
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    18
See COPYING file for the full LGPL text.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    19
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    20
Original ZIP package is copyrighted by Gilles Vollant, see
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    21
quazip/(un)zip.h files for details, basically it's zlib license.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    22
 **/
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    23
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    24
#include <QFile>
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    25
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    26
#include "quazip.h"
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    27
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    28
class QuaZipPrivate {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    29
  friend class QuaZip;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    30
  private:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    31
    QTextCodec *fileNameCodec, *commentCodec;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    32
    QString zipName;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    33
    QIODevice *ioDevice;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    34
    QString comment;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    35
    QuaZip::Mode mode;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    36
    union {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    37
      unzFile unzFile_f;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    38
      zipFile zipFile_f;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    39
    };
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    40
    bool hasCurrentFile_f;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    41
    int zipError;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    42
    inline QuaZipPrivate():
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    43
      fileNameCodec(QTextCodec::codecForLocale()),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    44
      commentCodec(QTextCodec::codecForLocale()),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    45
      ioDevice(NULL),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    46
      mode(QuaZip::mdNotOpen),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    47
      hasCurrentFile_f(false),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    48
      zipError(UNZ_OK) {}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    49
    inline QuaZipPrivate(const QString &zipName):
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    50
      fileNameCodec(QTextCodec::codecForLocale()),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    51
      commentCodec(QTextCodec::codecForLocale()),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    52
      zipName(zipName),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    53
      ioDevice(NULL),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    54
      mode(QuaZip::mdNotOpen),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    55
      hasCurrentFile_f(false),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    56
      zipError(UNZ_OK) {}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    57
    inline QuaZipPrivate(QIODevice *ioDevice):
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    58
      fileNameCodec(QTextCodec::codecForLocale()),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    59
      commentCodec(QTextCodec::codecForLocale()),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    60
      ioDevice(ioDevice),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    61
      mode(QuaZip::mdNotOpen),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    62
      hasCurrentFile_f(false),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    63
      zipError(UNZ_OK) {}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    64
};
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    65
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    66
QuaZip::QuaZip():
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    67
  p(new QuaZipPrivate())
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    68
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    69
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    70
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    71
QuaZip::QuaZip(const QString& zipName):
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    72
  p(new QuaZipPrivate(zipName))
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    73
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    74
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    75
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    76
QuaZip::QuaZip(QIODevice *ioDevice):
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    77
  p(new QuaZipPrivate(ioDevice))
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    78
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    79
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    80
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    81
QuaZip::~QuaZip()
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    82
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    83
  if(isOpen())
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    84
    close();
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    85
  delete p;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    86
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    87
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    88
bool QuaZip::open(Mode mode, zlib_filefunc_def* ioApi)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    89
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    90
  p->zipError=UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    91
  if(isOpen()) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    92
    qWarning("QuaZip::open(): ZIP already opened");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    93
    return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    94
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    95
  QIODevice *ioDevice = p->ioDevice;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    96
  if (ioDevice == NULL) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    97
    if (p->zipName.isEmpty()) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    98
      qWarning("QuaZip::open(): set either ZIP file name or IO device first");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    99
      return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   100
    } else {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   101
      ioDevice = new QFile(p->zipName);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   102
    }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   103
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   104
  switch(mode) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   105
    case mdUnzip:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   106
      p->unzFile_f=unzOpen2(ioDevice, ioApi);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   107
      if(p->unzFile_f!=NULL) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   108
        p->mode=mode;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   109
        p->ioDevice = ioDevice;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   110
        return true;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   111
      } else {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   112
        p->zipError=UNZ_OPENERROR;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   113
        if (!p->zipName.isEmpty())
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   114
          delete ioDevice;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   115
        return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   116
      }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   117
    case mdCreate:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   118
    case mdAppend:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   119
    case mdAdd:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   120
      p->zipFile_f=zipOpen2(ioDevice,
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   121
          mode==mdCreate?APPEND_STATUS_CREATE:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   122
          mode==mdAppend?APPEND_STATUS_CREATEAFTER:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   123
          APPEND_STATUS_ADDINZIP,
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   124
          NULL,
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   125
          ioApi);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   126
      if(p->zipFile_f!=NULL) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   127
        p->mode=mode;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   128
        p->ioDevice = ioDevice;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   129
        return true;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   130
      } else {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   131
        p->zipError=UNZ_OPENERROR;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   132
        if (!p->zipName.isEmpty())
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   133
          delete ioDevice;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   134
        return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   135
      }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   136
    default:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   137
      qWarning("QuaZip::open(): unknown mode: %d", (int)mode);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   138
      if (!p->zipName.isEmpty())
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   139
        delete ioDevice;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   140
      return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   141
      break;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   142
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   143
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   144
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   145
void QuaZip::close()
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   146
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   147
  p->zipError=UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   148
  switch(p->mode) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   149
    case mdNotOpen:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   150
      qWarning("QuaZip::close(): ZIP is not open");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   151
      return;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   152
    case mdUnzip:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   153
      p->zipError=unzClose(p->unzFile_f);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   154
      break;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   155
    case mdCreate:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   156
    case mdAppend:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   157
    case mdAdd:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   158
      p->zipError=zipClose(p->zipFile_f, p->commentCodec->fromUnicode(p->comment).constData());
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   159
      break;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   160
    default:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   161
      qWarning("QuaZip::close(): unknown mode: %d", (int)p->mode);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   162
      return;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   163
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   164
  // opened by name, need to delete the internal IO device
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   165
  if (!p->zipName.isEmpty())
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   166
    delete p->ioDevice;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   167
  if(p->zipError==UNZ_OK)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   168
    p->mode=mdNotOpen;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   169
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   170
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   171
void QuaZip::setZipName(const QString& zipName)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   172
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   173
  if(isOpen()) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   174
    qWarning("QuaZip::setZipName(): ZIP is already open!");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   175
    return;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   176
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   177
  p->zipName=zipName;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   178
  p->ioDevice = NULL;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   179
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   180
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   181
void QuaZip::setIoDevice(QIODevice *ioDevice)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   182
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   183
  if(isOpen()) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   184
    qWarning("QuaZip::setIoDevice(): ZIP is already open!");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   185
    return;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   186
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   187
  p->ioDevice = ioDevice;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   188
  p->zipName = QString();
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   189
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   190
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   191
int QuaZip::getEntriesCount()const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   192
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   193
  QuaZip *fakeThis=(QuaZip*)this; // non-const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   194
  fakeThis->p->zipError=UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   195
  if(p->mode!=mdUnzip) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   196
    qWarning("QuaZip::getEntriesCount(): ZIP is not open in mdUnzip mode");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   197
    return -1;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   198
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   199
  unz_global_info globalInfo;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   200
  if((fakeThis->p->zipError=unzGetGlobalInfo(p->unzFile_f, &globalInfo))!=UNZ_OK)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   201
    return p->zipError;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   202
  return (int)globalInfo.number_entry;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   203
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   204
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   205
QString QuaZip::getComment()const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   206
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   207
  QuaZip *fakeThis=(QuaZip*)this; // non-const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   208
  fakeThis->p->zipError=UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   209
  if(p->mode!=mdUnzip) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   210
    qWarning("QuaZip::getComment(): ZIP is not open in mdUnzip mode");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   211
    return QString();
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   212
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   213
  unz_global_info globalInfo;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   214
  QByteArray comment;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   215
  if((fakeThis->p->zipError=unzGetGlobalInfo(p->unzFile_f, &globalInfo))!=UNZ_OK)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   216
    return QString();
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   217
  comment.resize(globalInfo.size_comment);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   218
  if((fakeThis->p->zipError=unzGetGlobalComment(p->unzFile_f, comment.data(), comment.size())) < 0)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   219
    return QString();
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   220
  fakeThis->p->zipError = UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   221
  return p->commentCodec->toUnicode(comment);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   222
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   223
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   224
bool QuaZip::setCurrentFile(const QString& fileName, CaseSensitivity cs)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   225
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   226
  p->zipError=UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   227
  if(p->mode!=mdUnzip) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   228
    qWarning("QuaZip::setCurrentFile(): ZIP is not open in mdUnzip mode");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   229
    return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   230
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   231
  if(fileName.isEmpty()) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   232
    p->hasCurrentFile_f=false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   233
    return true;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   234
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   235
  // Unicode-aware reimplementation of the unzLocateFile function
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   236
  if(p->unzFile_f==NULL) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   237
    p->zipError=UNZ_PARAMERROR;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   238
    return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   239
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   240
  if(fileName.length()>MAX_FILE_NAME_LENGTH) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   241
    p->zipError=UNZ_PARAMERROR;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   242
    return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   243
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   244
  bool sens;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   245
  if(cs==csDefault) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   246
#ifdef Q_WS_WIN
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   247
    sens=false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   248
#else
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   249
    sens=true;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   250
#endif
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   251
  } else sens=cs==csSensitive;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   252
  QString lower, current;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   253
  if(!sens) lower=fileName.toLower();
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   254
  p->hasCurrentFile_f=false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   255
  for(bool more=goToFirstFile(); more; more=goToNextFile()) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   256
    current=getCurrentFileName();
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   257
    if(current.isEmpty()) return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   258
    if(sens) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   259
      if(current==fileName) break;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   260
    } else {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   261
      if(current.toLower()==lower) break;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   262
    }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   263
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   264
  return p->hasCurrentFile_f;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   265
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   266
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   267
bool QuaZip::goToFirstFile()
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   268
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   269
  p->zipError=UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   270
  if(p->mode!=mdUnzip) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   271
    qWarning("QuaZip::goToFirstFile(): ZIP is not open in mdUnzip mode");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   272
    return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   273
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   274
  p->zipError=unzGoToFirstFile(p->unzFile_f);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   275
  p->hasCurrentFile_f=p->zipError==UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   276
  return p->hasCurrentFile_f;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   277
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   278
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   279
bool QuaZip::goToNextFile()
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   280
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   281
  p->zipError=UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   282
  if(p->mode!=mdUnzip) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   283
    qWarning("QuaZip::goToFirstFile(): ZIP is not open in mdUnzip mode");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   284
    return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   285
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   286
  p->zipError=unzGoToNextFile(p->unzFile_f);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   287
  p->hasCurrentFile_f=p->zipError==UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   288
  if(p->zipError==UNZ_END_OF_LIST_OF_FILE)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   289
    p->zipError=UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   290
  return p->hasCurrentFile_f;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   291
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   292
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   293
bool QuaZip::getCurrentFileInfo(QuaZipFileInfo *info)const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   294
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   295
  QuaZip *fakeThis=(QuaZip*)this; // non-const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   296
  fakeThis->p->zipError=UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   297
  if(p->mode!=mdUnzip) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   298
    qWarning("QuaZip::getCurrentFileInfo(): ZIP is not open in mdUnzip mode");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   299
    return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   300
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   301
  unz_file_info info_z;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   302
  QByteArray fileName;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   303
  QByteArray extra;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   304
  QByteArray comment;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   305
  if(info==NULL) return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   306
  if(!isOpen()||!hasCurrentFile()) return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   307
  if((fakeThis->p->zipError=unzGetCurrentFileInfo(p->unzFile_f, &info_z, NULL, 0, NULL, 0, NULL, 0))!=UNZ_OK)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   308
    return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   309
  fileName.resize(info_z.size_filename);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   310
  extra.resize(info_z.size_file_extra);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   311
  comment.resize(info_z.size_file_comment);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   312
  if((fakeThis->p->zipError=unzGetCurrentFileInfo(p->unzFile_f, NULL,
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   313
      fileName.data(), fileName.size(),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   314
      extra.data(), extra.size(),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   315
      comment.data(), comment.size()))!=UNZ_OK)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   316
    return false;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   317
  info->versionCreated=info_z.version;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   318
  info->versionNeeded=info_z.version_needed;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   319
  info->flags=info_z.flag;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   320
  info->method=info_z.compression_method;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   321
  info->crc=info_z.crc;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   322
  info->compressedSize=info_z.compressed_size;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   323
  info->uncompressedSize=info_z.uncompressed_size;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   324
  info->diskNumberStart=info_z.disk_num_start;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   325
  info->internalAttr=info_z.internal_fa;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   326
  info->externalAttr=info_z.external_fa;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   327
  info->name=p->fileNameCodec->toUnicode(fileName);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   328
  info->comment=p->commentCodec->toUnicode(comment);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   329
  info->extra=extra;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   330
  info->dateTime=QDateTime(
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   331
      QDate(info_z.tmu_date.tm_year, info_z.tmu_date.tm_mon+1, info_z.tmu_date.tm_mday),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   332
      QTime(info_z.tmu_date.tm_hour, info_z.tmu_date.tm_min, info_z.tmu_date.tm_sec));
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   333
  return true;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   334
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   335
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   336
QString QuaZip::getCurrentFileName()const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   337
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   338
  QuaZip *fakeThis=(QuaZip*)this; // non-const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   339
  fakeThis->p->zipError=UNZ_OK;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   340
  if(p->mode!=mdUnzip) {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   341
    qWarning("QuaZip::getCurrentFileName(): ZIP is not open in mdUnzip mode");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   342
    return QString();
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   343
  }
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   344
  if(!isOpen()||!hasCurrentFile()) return QString();
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   345
  QByteArray fileName(MAX_FILE_NAME_LENGTH, 0);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   346
  if((fakeThis->p->zipError=unzGetCurrentFileInfo(p->unzFile_f, NULL, fileName.data(), fileName.size(),
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   347
      NULL, 0, NULL, 0))!=UNZ_OK)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   348
    return QString();
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   349
  return p->fileNameCodec->toUnicode(fileName.constData());
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   350
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   351
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   352
void QuaZip::setFileNameCodec(QTextCodec *fileNameCodec)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   353
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   354
  p->fileNameCodec=fileNameCodec;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   355
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   356
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   357
void QuaZip::setFileNameCodec(const char *fileNameCodecName)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   358
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   359
  p->fileNameCodec=QTextCodec::codecForName(fileNameCodecName);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   360
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   361
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   362
QTextCodec *QuaZip::getFileNameCodec()const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   363
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   364
  return p->fileNameCodec;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   365
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   366
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   367
void QuaZip::setCommentCodec(QTextCodec *commentCodec)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   368
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   369
  p->commentCodec=commentCodec;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   370
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   371
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   372
void QuaZip::setCommentCodec(const char *commentCodecName)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   373
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   374
  p->commentCodec=QTextCodec::codecForName(commentCodecName);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   375
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   376
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   377
QTextCodec *QuaZip::getCommentCodec()const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   378
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   379
  return p->commentCodec;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   380
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   381
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   382
QString QuaZip::getZipName() const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   383
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   384
  return p->zipName;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   385
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   386
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   387
QIODevice *QuaZip::getIoDevice() const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   388
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   389
  if (!p->zipName.isEmpty()) // opened by name, using an internal QIODevice
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   390
    return NULL;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   391
  return p->ioDevice;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   392
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   393
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   394
QuaZip::Mode QuaZip::getMode()const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   395
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   396
  return p->mode;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   397
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   398
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   399
bool QuaZip::isOpen()const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   400
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   401
  return p->mode!=mdNotOpen;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   402
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   403
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   404
int QuaZip::getZipError() const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   405
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   406
  return p->zipError;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   407
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   408
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   409
void QuaZip::setComment(const QString& comment)
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   410
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   411
  p->comment=comment;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   412
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   413
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   414
bool QuaZip::hasCurrentFile()const
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   415
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   416
  return p->hasCurrentFile_f;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   417
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   418
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   419
unzFile QuaZip::getUnzFile()
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   420
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   421
  return p->unzFile_f;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   422
}
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   423
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   424
zipFile QuaZip::getZipFile()
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   425
{
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   426
  return p->zipFile_f;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   427
}