[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZGZIPZLIBCompressionHandler class 4 // 5 // Created on: <13-Aug-2003 16:20:19 amos> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezgzipzlibcompressionhandler.php 30 */ 31 32 /*! 33 \class eZGZIPZLIBCompressionHandler ezgzipzlibcompressionhandler.php 34 \brief Handles files compressed with gzip using the zlib extension 35 36 More information on the zlib extension can be found here: 37 http://www.php.net/manual/en/ref.zlib.php 38 */ 39 40 include_once ( 'lib/ezfile/classes/ezcompressionhandler.php' ); 41 42 class eZGZIPZLIBCompressionHandler extends eZCompressionHandler 43 { 44 /*! 45 */ 46 function eZGZIPZLIBCompressionHandler() 47 { 48 $this->File = false; 49 $this->Level = false; 50 $this->eZCompressionHandler( 'GZIP (zlib)', 'gzipzlib' ); 51 } 52 53 /*! 54 Sets the current compression level. 55 */ 56 function setCompressionLevel( $level ) 57 { 58 if ( $level < 0 or $level > 9 ) 59 $level = false; 60 $this->Level = $level; 61 } 62 63 /*! 64 \return the current compression level which is a number between 0 and 9, 65 or \c false if the default is to be used. 66 */ 67 function compressionLevel() 68 { 69 return $this->Level; 70 } 71 72 /*! 73 \return true if this handler can be used. 74 This function checks if the zlib extension is available. 75 */ 76 function isAvailable() 77 { 78 $extensionName = 'zlib'; 79 if ( !extension_loaded( $extensionName ) ) 80 { 81 $dlExtension = ( eZSys::osType() == 'win32' ) ? '.dll' : '.so'; 82 @dl( $extensionName . $dlExtension ); 83 } 84 return extension_loaded( $extensionName ); 85 } 86 87 /*! 88 \reimp 89 */ 90 function doOpen( $filename, $mode ) 91 { 92 $this->File = @gzopen( $filename, $mode ); 93 return $this->File; 94 } 95 96 /*! 97 \reimp 98 */ 99 function doClose() 100 { 101 $result = @gzclose( $this->File ); 102 $this->File = false; 103 return $result; 104 } 105 106 /*! 107 \reimp 108 */ 109 function doRead( $uncompressedLength = false ) 110 { 111 return @gzread( $this->File, $uncompressedLength ); 112 } 113 114 /*! 115 \reimp 116 */ 117 function doWrite( $data, $uncompressedLength = false ) 118 { 119 if ( $uncompressedLength ) 120 return @gzwrite( $this->File, $data, $uncompressedLength ); 121 else 122 return @gzwrite( $this->File, $data ); 123 } 124 125 /*! 126 \reimp 127 */ 128 function doFlush() 129 { 130 return @fflush( $this->File ); 131 } 132 133 /*! 134 \reimp 135 */ 136 function doSeek( $offset, $whence ) 137 { 138 if ( $whence == SEEK_CUR ) 139 { 140 $offset = gztell( $this->File ) + $offset; 141 } 142 else if ( $whence == SEEK_END ) 143 { 144 eZDebug::writeError( "Seeking from end is not supported for gzipped files", 145 'eZGZIPZLIBCompressionHandler::doSeek' ); 146 return false; 147 } 148 return @gzseek( $this->File, $offset ); 149 } 150 151 /*! 152 \reimp 153 */ 154 function doRewind() 155 { 156 return @gzrewind( $this->File ); 157 } 158 159 /*! 160 \reimp 161 */ 162 function doTell() 163 { 164 return @gztell( $this->File ); 165 } 166 167 /*! 168 \reimp 169 */ 170 function doEOF() 171 { 172 return @gzeof( $this->File ); 173 } 174 175 /*! 176 \reimp 177 */ 178 function doPasstrough( $closeFile) 179 { 180 $result = @gzpasstru( $this->File ); 181 if ( !$closeFile ) 182 { 183 // The file must be reopened because gzpasstru will close the file. 184 $this->File = @gzopen( $this->filename(), $this->mode(), $this->isBinaryMode() ); 185 } 186 else 187 $this->File = false; 188 return $result; 189 } 190 191 /*! 192 \reimp 193 */ 194 function compress( $source ) 195 { 196 return @gzcompress( $source, $this->Level ); 197 } 198 199 /*! 200 \reimp 201 */ 202 function decompress( $source ) 203 { 204 return @gzuncompress( $source ); 205 } 206 207 /*! 208 \reimp 209 */ 210 function errorString() 211 { 212 return false; 213 } 214 215 /*! 216 \reimp 217 */ 218 function errorNumber() 219 { 220 return false; 221 } 222 223 /// \privatesection 224 /// File pointer, returned by gzopen 225 var $File; 226 /// The compression level 227 var $Level; 228 } 229 230 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |