GH-1227 renam GZip functions to not collide with zlib macros

This commit is contained in:
Petr Mrázek 2015-09-14 02:36:03 +02:00
parent e38cc1d480
commit dd8eacee1b
5 changed files with 10 additions and 8 deletions

View File

@ -130,7 +130,7 @@ void OtherLogsPage::on_btnReload_clicked()
if(file.fileName().endsWith(".gz")) if(file.fileName().endsWith(".gz"))
{ {
QByteArray temp; QByteArray temp;
if(!GZip::decompress(file.readAll(), temp)) if(!GZip::unzip(file.readAll(), temp))
{ {
ui->text->setPlainText( ui->text->setPlainText(
tr("The file (%1) is not readable.").arg(file.fileName())); tr("The file (%1) is not readable.").arg(file.fileName()));

View File

@ -2,7 +2,7 @@
#include <zlib.h> #include <zlib.h>
#include <QByteArray> #include <QByteArray>
bool GZip::decompress(const QByteArray &compressedBytes, QByteArray &uncompressedBytes) bool GZip::unzip(const QByteArray &compressedBytes, QByteArray &uncompressedBytes)
{ {
if (compressedBytes.size() == 0) if (compressedBytes.size() == 0)
{ {
@ -59,7 +59,7 @@ bool GZip::decompress(const QByteArray &compressedBytes, QByteArray &uncompresse
return true; return true;
} }
bool GZip::compress(const QByteArray &uncompressedBytes, QByteArray &compressedBytes) bool GZip::zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes)
{ {
if (uncompressedBytes.size() == 0) if (uncompressedBytes.size() == 0)
{ {

View File

@ -6,7 +6,7 @@
class MULTIMC_LOGIC_EXPORT GZip class MULTIMC_LOGIC_EXPORT GZip
{ {
public: public:
static bool decompress(const QByteArray &compressedBytes, QByteArray &uncompressedBytes); static bool unzip(const QByteArray &compressedBytes, QByteArray &uncompressedBytes);
static bool compress(const QByteArray &uncompressedBytes, QByteArray &compressedBytes); static bool zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes);
}; };

View File

@ -187,7 +187,7 @@ static int64_t read_long (nbt::value& parent, const char * name, const int64_t &
void World::parseLevelDat(QByteArray data) void World::parseLevelDat(QByteArray data)
{ {
QByteArray output; QByteArray output;
is_valid = GZip::decompress(data, output); is_valid = GZip::unzip(data, output);
if(!is_valid) if(!is_valid)
{ {
return; return;

View File

@ -42,8 +42,10 @@ slots:
{ {
QByteArray copy = random; QByteArray copy = random;
copy.resize(cur); copy.resize(cur);
QVERIFY(GZip::compress(copy, compressed)); compressed.clear();
QVERIFY(GZip::decompress(compressed, decompressed)); decompressed.clear();
QVERIFY(GZip::zip(copy, compressed));
QVERIFY(GZip::unzip(compressed, decompressed));
QCOMPARE(decompressed, copy); QCOMPARE(decompressed, copy);
fib(prev, cur); fib(prev, cur);
} while (cur < size); } while (cur < size);