From f678e63bd823fa712e9fbb28c259fcbedc30aa45 Mon Sep 17 00:00:00 2001 From: garrettair Date: Tue, 18 Nov 2014 17:09:31 -0600 Subject: Exposed the arguments to gzcompress by adding public variables to the Zip library. --- system/libraries/Zip.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 434229471..5208c9149 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -95,6 +95,19 @@ class CI_Zip { * @var int */ public $now; + + /** + * The level of compression. 0 to 9, 9 being the highest level of + * compression. + * @var int + */ + public $compression_level = 6; + + /** + * Which encoding to use. One of the ZLIB_ENCODING_* constants. + * @var int + */ + public $compression_encoding = ZLIB_ENCODING_DEFLATE; /** * Initialize zip compression class @@ -248,7 +261,7 @@ class CI_Zip { $uncompressed_size = strlen($data); $crc32 = crc32($data); - $gzdata = substr(gzcompress($data), 2, -4); + $gzdata = substr(gzcompress($data, $this->compression_level, $this->compression_encoding), 2, -4); $compressed_size = strlen($gzdata); $this->zipdata .= -- cgit v1.2.3-24-g4f1b From 4a25cff212e4eb06bb4806f49054bd8b48c802a6 Mon Sep 17 00:00:00 2001 From: garrettair Date: Wed, 3 Dec 2014 15:17:32 -0600 Subject: Updated changelog to include changes to the Zip Library. Signed-off-by: garrettair --- user_guide_src/source/changelog.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 242881c99..00cdd58c5 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -420,7 +420,11 @@ Release Date: Not Released - Added method chaining support. - Added support for setting table class defaults in a config file. - - :doc:`Zip Library ` method ``read_file()`` can now also alter the original file path/name while adding files to an archive. + - :doc:`Zip Library ` changes include: + + - Method ``read_file()`` can now also alter the original file path/name while adding files to an archive. + - Added support for changing the compression level and encoding used by gzcompress. + - :doc:`Trackback Library ` method ``receive()`` will now utilize ``iconv()`` if it is available but ``mb_convert_encoding()`` is not. - Core -- cgit v1.2.3-24-g4f1b From d187847cd09eaacb881ddebe74416fdfa7a6ead9 Mon Sep 17 00:00:00 2001 From: garrettair Date: Wed, 3 Dec 2014 15:28:07 -0600 Subject: Updated Zip Library documentation to mention compression features. Signed-off-by: garrettair --- user_guide_src/source/libraries/zip.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/user_guide_src/source/libraries/zip.rst b/user_guide_src/source/libraries/zip.rst index 4ca14086a..a6b98c2ac 100644 --- a/user_guide_src/source/libraries/zip.rst +++ b/user_guide_src/source/libraries/zip.rst @@ -88,6 +88,11 @@ Class Reference The above example will place my_bio.txt inside a folder called personal. + You can change the level of compression and encoding that is used by the gzcompress function during compression:: + + $this->zip->compression_level = 0; // Disable compression + $this->zip->compression_encoding = ZLIB_ENCODING_GZIP; + .. method:: add_dir($directory) :param mixed $directory: Directory name string or an array of multiple directories -- cgit v1.2.3-24-g4f1b