Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezgzipzlibcompressionhandler.php
Go to the documentation of this file.
1 <?php
19 class eZGZIPZLIBCompressionHandler extends eZCompressionHandler
20 {
21 public function __construct()
22 {
23 $this->File = false;
24 $this->Level = false;
25 parent::__construct( 'GZIP (zlib)', 'gzipzlib' );
26 }
27
31 function setCompressionLevel( $level )
32 {
33 if ( $level < 0 or $level > 9 )
34 $level = false;
35 $this->Level = $level;
36 }
37
42 function compressionLevel()
43 {
44 return $this->Level;
45 }
46
51 static function isAvailable()
52 {
53 // Only check a few of the functions, it's assumed all used gz methods are here if these two are present
54 return function_exists('gzcompress') && function_exists('gzuncompress');
55 }
56
57 function doOpen( $filename, $mode )
58 {
59 $this->File = @gzopen( $filename, $mode );
60 return $this->File;
61 }
62
63 function doClose()
64 {
65 $result = @gzclose( $this->File );
66 $this->File = false;
67 return $result;
68 }
69
70 function doRead( $uncompressedLength = false )
71 {
72 return @gzread( $this->File, $uncompressedLength );
73 }
74
75 function doWrite( $data, $uncompressedLength = false )
76 {
77 if ( $uncompressedLength )
78 return @gzwrite( $this->File, $data, $uncompressedLength );
79 else
80 return @gzwrite( $this->File, $data );
81 }
82
83 function doFlush()
84 {
85 return @fflush( $this->File );
86 }
87
88 function doSeek( $offset, $whence )
89 {
90 if ( $whence == SEEK_CUR )
91 {
92 $offset = gztell( $this->File ) + $offset;
93 }
94 else if ( $whence == SEEK_END )
95 {
96 eZDebug::writeError( "Seeking from end is not supported for gzipped files", __METHOD__ );
97 return false;
98 }
99 return @gzseek( $this->File, $offset );
100 }
101
102 function doRewind()
103 {
104 return @gzrewind( $this->File );
105 }
106
107 function doTell()
108 {
109 return @gztell( $this->File );
110 }
111
112 function doEOF()
113 {
114 return @gzeof( $this->File );
115 }
116
117 function doPasstrough( $closeFile = true )
118 {
119 $result = @gzpassthru( $this->File );
120 if ( !$closeFile )
121 {
122 // The file must be reopened because gzpasstru will close the file.
123 $this->File = @gzopen( $this->filename(), $this->mode(), $this->isBinaryMode() );
124 }
125 else
126 $this->File = false;
127 return $result;
128 }
129
130 function compress( $source )
131 {
132 return @gzcompress( $source, $this->Level );
133 }
134
135 function decompress( $source )
136 {
137 return @gzuncompress( $source );
138 }
139
140 function errorString()
141 {
142 return false;
143 }
144
145 function errorNumber()
146 {
147 return false;
148 }
149
152 public $File;
154 public $Level;
155 }
156
157 ?>
eZCompressionHandler
Interface for file handlers using compression.
Definition: ezcompressionhandler.php:34
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZFileHandler\mode
mode()
Definition: ezfilehandler.php:108
eZFileHandler\isBinaryMode
isBinaryMode()
Definition: ezfilehandler.php:92
eZFileHandler\filename
filename()
Definition: ezfilehandler.php:100
eZGZIPZLIBCompressionHandler
Handles files compressed with gzip using the zlib extension.
Definition: ezgzipzlibcompressionhandler.php:20
eZGZIPZLIBCompressionHandler\doWrite
doWrite( $data, $uncompressedLength=false)
Definition: ezgzipzlibcompressionhandler.php:75
eZGZIPZLIBCompressionHandler\doFlush
doFlush()
Definition: ezgzipzlibcompressionhandler.php:83
eZGZIPZLIBCompressionHandler\errorString
errorString()
Definition: ezgzipzlibcompressionhandler.php:140
eZGZIPZLIBCompressionHandler\__construct
__construct()
Definition: ezgzipzlibcompressionhandler.php:21
eZGZIPZLIBCompressionHandler\compress
compress( $source)
Definition: ezgzipzlibcompressionhandler.php:130
eZGZIPZLIBCompressionHandler\doOpen
doOpen( $filename, $mode)
Definition: ezgzipzlibcompressionhandler.php:57
eZGZIPZLIBCompressionHandler\doTell
doTell()
Definition: ezgzipzlibcompressionhandler.php:107
eZGZIPZLIBCompressionHandler\compressionLevel
compressionLevel()
Definition: ezgzipzlibcompressionhandler.php:42
eZGZIPZLIBCompressionHandler\errorNumber
errorNumber()
Definition: ezgzipzlibcompressionhandler.php:145
eZGZIPZLIBCompressionHandler\doEOF
doEOF()
Definition: ezgzipzlibcompressionhandler.php:112
eZGZIPZLIBCompressionHandler\doSeek
doSeek( $offset, $whence)
Definition: ezgzipzlibcompressionhandler.php:88
eZGZIPZLIBCompressionHandler\$Level
$Level
The compression level.
Definition: ezgzipzlibcompressionhandler.php:154
eZGZIPZLIBCompressionHandler\decompress
decompress( $source)
Definition: ezgzipzlibcompressionhandler.php:135
eZGZIPZLIBCompressionHandler\doClose
doClose()
Definition: ezgzipzlibcompressionhandler.php:63
eZGZIPZLIBCompressionHandler\setCompressionLevel
setCompressionLevel( $level)
Definition: ezgzipzlibcompressionhandler.php:31
eZGZIPZLIBCompressionHandler\doPasstrough
doPasstrough( $closeFile=true)
Definition: ezgzipzlibcompressionhandler.php:117
eZGZIPZLIBCompressionHandler\doRewind
doRewind()
Definition: ezgzipzlibcompressionhandler.php:102
eZGZIPZLIBCompressionHandler\doRead
doRead( $uncompressedLength=false)
Definition: ezgzipzlibcompressionhandler.php:70
eZGZIPZLIBCompressionHandler\isAvailable
static isAvailable()
Definition: ezgzipzlibcompressionhandler.php:51
eZGZIPZLIBCompressionHandler\$File
$File
Definition: ezgzipzlibcompressionhandler.php:152
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.