diff options
author | Alex Zolotarev <alex@maps.me> | 2015-08-18 22:35:19 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 03:01:39 +0300 |
commit | a01c79c08fcad60bef9cd361a678c852e97403cf (patch) | |
tree | ce6ee7249619f4d752a5b50550882bb8b76f0947 /coding | |
parent | 877ee1ec3f4187dcc67d7117b5ccbecacc503a8e (diff) |
Replaced zlib with minizip which uses zlib from the operating system.
Diffstat (limited to 'coding')
-rw-r--r-- | coding/coding.pro | 4 | ||||
-rw-r--r-- | coding/coding_tests/coding_tests.pro | 3 | ||||
-rw-r--r-- | coding/coding_tests/gzip_test.cpp | 27 | ||||
-rw-r--r-- | coding/gzip_compressor.cpp | 39 | ||||
-rw-r--r-- | coding/gzip_compressor.hpp | 17 | ||||
-rw-r--r-- | coding/zip_creator.cpp | 2 | ||||
-rw-r--r-- | coding/zip_reader.cpp | 2 |
7 files changed, 4 insertions, 90 deletions
diff --git a/coding/coding.pro b/coding/coding.pro index d96d71eee1..d36cd54b6d 100644 --- a/coding/coding.pro +++ b/coding/coding.pro @@ -7,7 +7,7 @@ ROOT_DIR = .. include($$ROOT_DIR/common.pri) -INCLUDEPATH *= $$ROOT_DIR/3party/tomcrypt/src/headers $$ROOT_DIR/3party/zlib $$ROOT_DIR/3party/expat/lib +INCLUDEPATH *= $$ROOT_DIR/3party/tomcrypt/src/headers $$ROOT_DIR/3party/expat/lib SOURCES += \ arithmetic_codec.cpp \ @@ -20,7 +20,6 @@ SOURCES += \ file_name_utils.cpp \ file_reader.cpp \ file_writer.cpp \ - gzip_compressor.cpp \ hex.cpp \ huffman.cpp \ internal/file_data.cpp \ @@ -62,7 +61,6 @@ HEADERS += \ file_sort.hpp \ file_writer.hpp \ file_writer_stream.hpp \ - gzip_compressor.hpp \ hex.hpp \ huffman.hpp \ internal/expat_impl.h \ diff --git a/coding/coding_tests/coding_tests.pro b/coding/coding_tests/coding_tests.pro index 6ef69ca27f..c6aee3614e 100644 --- a/coding/coding_tests/coding_tests.pro +++ b/coding/coding_tests/coding_tests.pro @@ -5,7 +5,7 @@ CONFIG -= app_bundle TEMPLATE = app ROOT_DIR = ../.. -DEPENDENCIES = coding base zlib tomcrypt +DEPENDENCIES = coding base minizip tomcrypt include($$ROOT_DIR/common.pri) @@ -27,7 +27,6 @@ SOURCES += ../../testing/testingmain.cpp \ file_data_test.cpp \ file_sort_test.cpp \ file_utils_test.cpp \ - gzip_test.cpp \ hex_test.cpp \ huffman_test.cpp \ mem_file_reader_test.cpp \ diff --git a/coding/coding_tests/gzip_test.cpp b/coding/coding_tests/gzip_test.cpp deleted file mode 100644 index 143dd0965f..0000000000 --- a/coding/coding_tests/gzip_test.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "base/SRC_FIRST.hpp" -#include "testing/testing.hpp" - -#include "coding/coding_tests/coder_test.hpp" -#include "coding/gzip_compressor.hpp" - -namespace -{ - void CompressGZipLevel1(char const * pSrc, size_t srcSize, string & dst) - { - return CompressGZip(1, pSrc, srcSize, dst); - } - void CompressGZipLevel9(char const * pSrc, size_t srcSize, string & dst) - { - return CompressGZip(1, pSrc, srcSize, dst); - } -} - -UNIT_TEST(AaaaGZipCompressionLevel1) -{ - CoderAaaaTest(&CompressGZipLevel1, &DecompressGZip); -} - -UNIT_TEST(AaaaGZipCompressionLevel9) -{ - CoderAaaaTest(&CompressGZipLevel9, &DecompressGZip); -} diff --git a/coding/gzip_compressor.cpp b/coding/gzip_compressor.cpp deleted file mode 100644 index 34ed54d682..0000000000 --- a/coding/gzip_compressor.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "coding/gzip_compressor.hpp" -#include "coding/coder_util.hpp" -#include "base/assert.hpp" -#include "3party/zlib/zlib.h" - -size_t DecompressGZipIntoFixedSize(char const * pSrc, size_t srcSize, char * pDst, size_t dstSize) -{ - unsigned long dstUsed = dstSize; - int error = uncompress(reinterpret_cast<unsigned char *>(pDst), &dstUsed, - reinterpret_cast<unsigned char const *>(pSrc), srcSize); - switch (error) - { - case Z_OK: - return dstUsed; - case Z_BUF_ERROR: - return size_t(-1); - default: - MYTHROW(DecompressGZipException, (error, srcSize, dstSize, dstUsed)); - } -} - -void DecompressGZip(char const * pSrc, size_t srcSize, string & dst) -{ - FixedDstSizeCodeToString(&DecompressGZipIntoFixedSize, pSrc, srcSize, dst); -} - -void CompressGZip(int level, char const * pSrc, size_t srcSize, string & dst) -{ - ASSERT(level >= 1 && level <= 9, (level)); - dst.resize(compressBound(srcSize)); - unsigned long dstUsed = dst.size(); - int error = compress2(reinterpret_cast<unsigned char *>(&dst[0]), &dstUsed, - reinterpret_cast<unsigned char const *>(pSrc), srcSize, level); - if (error == Z_OK) - dst.resize(dstUsed); - else - MYTHROW(CompressGZipException, (error, srcSize, dst.size(), dstUsed)); -} - diff --git a/coding/gzip_compressor.hpp b/coding/gzip_compressor.hpp deleted file mode 100644 index 93f63d1ec6..0000000000 --- a/coding/gzip_compressor.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "coding/coder.hpp" -#include "base/base.hpp" -#include "base/exception.hpp" - -DECLARE_EXCEPTION(CompressGZipException, StringCodingException); -DECLARE_EXCEPTION(DecompressGZipException, StringCodingException); - -// Throws CompressGZipException on error. -void CompressGZip(int level, char const * pSrc, size_t srcSize, string & dst); - -// Throws DecompressGZipException on error. -void DecompressGZip(char const * pSrc, size_t srcSize, string & dst); - -// Returns -1 if dstSize is too small, otherwise the size of pDst used. -// Throws DecompressGZipException on error. -size_t DecompressGZipIntoFixedSize(char const * pSrc, size_t srcSize, char * pDst, size_t dstSize); diff --git a/coding/zip_creator.cpp b/coding/zip_creator.cpp index e3443f0f96..2831100f3c 100644 --- a/coding/zip_creator.cpp +++ b/coding/zip_creator.cpp @@ -15,7 +15,7 @@ #include "std/algorithm.hpp" #include "std/unique_ptr.hpp" -#include "3party/zlib/contrib/minizip/zip.h" +#include "3party/minizip/zip.h" namespace diff --git a/coding/zip_reader.cpp b/coding/zip_reader.cpp index ed7d6b3f09..773096eb28 100644 --- a/coding/zip_reader.cpp +++ b/coding/zip_reader.cpp @@ -8,7 +8,7 @@ #include "std/bind.hpp" -#include "3party/zlib/contrib/minizip/unzip.h" +#include "3party/minizip/unzip.h" ZipFileReader::ZipFileReader(string const & container, string const & file, |