6 V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
7 Contributed by Ross Smith (adodb@netebb.com).
8 Released under both BSD license and Lesser GPL library license.
9 Whenever there is any discrepancy between the two licenses,
10 the BSD license will take precedence.
11 Set tabs to 4 for best viewing.
15 if (!function_exists('gzcompress')) {
16 trigger_error('gzip functions are not available', E_USER_ERROR
);
22 class ADODB_Compress_Gzip
{
39 function setLevel($level) {
40 assert('$level >= 0');
41 assert('$level <= 9');
42 $this->_level
= (int) $level;
47 function getMinLength() {
48 return $this->_min_length
;
53 function setMinLength($min_length) {
54 assert('$min_length >= 0');
55 $this->_min_length
= (int) $min_length;
60 function ADODB_Compress_Gzip($level = null, $min_length = null) {
61 if (!is_null($level)) {
62 $this->setLevel($level);
65 if (!is_null($min_length)) {
66 $this->setMinLength($min_length);
72 function write($data, $key) {
73 if (strlen($data) < $this->_min_length
) {
77 if (!is_null($this->_level
)) {
78 return gzcompress($data, $this->_level
);
80 return gzcompress($data);
86 function read($data, $key) {
87 return $data ?
gzuncompress($data) : $data;