ff7tk  0.02
Toolkit for making FF7 Tools
GZIPPS.cpp
Go to the documentation of this file.
1 /****************************************************************************
2  ** Néo-Midgar Final Fantasy VII French Retranslation
3  ** Copyright (C) 2009-2012 Arzel Jérôme <myst6re@gmail.com>
4  **
5  ** This program is free software: you can redistribute it and/or modify
6  ** it under the terms of the GNU General Public License as published by
7  ** the Free Software Foundation, either version 3 of the License, or
8  ** (at your option) any later version.
9  **
10  ** This program is distributed in the hope that it will be useful,
11  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  ** GNU General Public License for more details.
14  **
15  ** You should have received a copy of the GNU General Public License
16  ** along with this program. If not, see <http://www.gnu.org/licenses/>.
17  ****************************************************************************/
18 #include "GZIPPS.h"
19 
20 QByteArray GZIPPS::decompress(const char *data, int size)
21 {
22  if (size <= GZIPPS_HEADER_SIZE) {
23  return QByteArray();
24  }
25 
26  quint32 decSize;
27  memcpy(&decSize, data, 4);
28  return GZIP::decompress(data + GZIPPS_HEADER_SIZE, size - GZIPPS_HEADER_SIZE, decSize);
29 }
30 
31 QByteArray GZIPPS::compress(const char *ungzip, int size, const QByteArray &header, int level)
32 {
33  Q_ASSERT(header.size() == 4);
34 
35  QByteArray ret;
36  ret.append((char *)&size, 4); // = decSize
37  ret.append(header);
38  return ret.append(GZIP::compress(ungzip, size, level));
39 }
static QByteArray compress(const QByteArray &ungzip, int level=-1, Strategy strategy=StrategyDefault)
Definition: GZIP.cpp:27
static QByteArray decompress(const QByteArray &data)
Definition: GZIPPS.h:28
static QByteArray compress(const QByteArray &ungzip, const QByteArray &header, int level=-1)
Definition: GZIPPS.h:31
#define GZIPPS_HEADER_SIZE
Definition: GZIPPS.h:23
static QByteArray decompress(const QByteArray &data, int decSize, Strategy strategy=StrategyDefault)
Definition: GZIP.cpp:22