diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2023-08-14 18:16:53 +0200 |
---|---|---|
committer | Sefa Eyeoglu <contact@scrumplex.net> | 2023-08-14 18:16:53 +0200 |
commit | 91ba4cf75ee30c64779edb5b7644e5a830de5026 (patch) | |
tree | aa8c2433bfc3a54577aceeb706c4c2cd0986c95d /launcher/GZip.cpp | |
parent | 779f70057b021e285afd60cc650a14cd5feacffd (diff) | |
download | PrismLauncher-91ba4cf75ee30c64779edb5b7644e5a830de5026.tar.gz PrismLauncher-91ba4cf75ee30c64779edb5b7644e5a830de5026.tar.bz2 PrismLauncher-91ba4cf75ee30c64779edb5b7644e5a830de5026.zip |
chore: reformat
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'launcher/GZip.cpp')
-rw-r--r-- | launcher/GZip.cpp | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/launcher/GZip.cpp b/launcher/GZip.cpp index e36dc8a4..292fab29 100644 --- a/launcher/GZip.cpp +++ b/launcher/GZip.cpp @@ -37,10 +37,9 @@ #include <zlib.h> #include <QByteArray> -bool GZip::unzip(const QByteArray &compressedBytes, QByteArray &uncompressedBytes) +bool GZip::unzip(const QByteArray& compressedBytes, QByteArray& uncompressedBytes) { - if (compressedBytes.size() == 0) - { + if (compressedBytes.size() == 0) { uncompressedBytes = compressedBytes; return true; } @@ -51,42 +50,37 @@ bool GZip::unzip(const QByteArray &compressedBytes, QByteArray &uncompressedByte z_stream strm; memset(&strm, 0, sizeof(strm)); - strm.next_in = (Bytef *)compressedBytes.data(); + strm.next_in = (Bytef*)compressedBytes.data(); strm.avail_in = compressedBytes.size(); bool done = false; - if (inflateInit2(&strm, (16 + MAX_WBITS)) != Z_OK) - { + if (inflateInit2(&strm, (16 + MAX_WBITS)) != Z_OK) { return false; } int err = Z_OK; - while (!done) - { + while (!done) { // If our output buffer is too small - if (strm.total_out >= uncompLength) - { + if (strm.total_out >= uncompLength) { uncompressedBytes.resize(uncompLength * 2); uncompLength *= 2; } - strm.next_out = reinterpret_cast<Bytef *>((uncompressedBytes.data() + strm.total_out)); + strm.next_out = reinterpret_cast<Bytef*>((uncompressedBytes.data() + strm.total_out)); strm.avail_out = uncompLength - strm.total_out; // Inflate another chunk. err = inflate(&strm, Z_SYNC_FLUSH); if (err == Z_STREAM_END) done = true; - else if (err != Z_OK) - { + else if (err != Z_OK) { break; } } - if (inflateEnd(&strm) != Z_OK || !done) - { + if (inflateEnd(&strm) != Z_OK || !done) { return false; } @@ -94,10 +88,9 @@ bool GZip::unzip(const QByteArray &compressedBytes, QByteArray &uncompressedByte return true; } -bool GZip::zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes) +bool GZip::zip(const QByteArray& uncompressedBytes, QByteArray& compressedBytes) { - if (uncompressedBytes.size() == 0) - { + if (uncompressedBytes.size() == 0) { compressedBytes = uncompressedBytes; return true; } @@ -109,8 +102,7 @@ bool GZip::zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes) z_stream zs; memset(&zs, 0, sizeof(zs)); - if (deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, (16 + MAX_WBITS), 8, Z_DEFAULT_STRATEGY) != Z_OK) - { + if (deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, (16 + MAX_WBITS), 8, Z_DEFAULT_STRATEGY) != Z_OK) { return false; } @@ -122,11 +114,9 @@ bool GZip::zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes) unsigned offset = 0; unsigned temp = 0; - do - { + do { auto remaining = compressedBytes.size() - offset; - if(remaining < 1) - { + if (remaining < 1) { compressedBytes.resize(compressedBytes.size() * 2); } zs.next_out = reinterpret_cast<Bytef*>((compressedBytes.data() + offset)); @@ -137,13 +127,11 @@ bool GZip::zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes) compressedBytes.resize(offset); - if (deflateEnd(&zs) != Z_OK) - { + if (deflateEnd(&zs) != Z_OK) { return false; } - if (ret != Z_STREAM_END) - { + if (ret != Z_STREAM_END) { return false; } return true; |