eZ Publish  [4.0]
ezgzipshellcompressionhandler.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZGZIPShellCompressionHandler class
00004 //
00005 // Created on: <13-Aug-2003 16:20:19 amos>
00006 //
00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00008 // SOFTWARE NAME: eZ Publish
00009 // SOFTWARE RELEASE: 4.0.x
00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00011 // SOFTWARE LICENSE: GNU General Public License v2.0
00012 // NOTICE: >
00013 //   This program is free software; you can redistribute it and/or
00014 //   modify it under the terms of version 2.0  of the GNU General
00015 //   Public License as published by the Free Software Foundation.
00016 //
00017 //   This program is distributed in the hope that it will be useful,
00018 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //   GNU General Public License for more details.
00021 //
00022 //   You should have received a copy of version 2.0 of the GNU General
00023 //   Public License along with this program; if not, write to the Free
00024 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 //   MA 02110-1301, USA.
00026 //
00027 //
00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00029 //
00030 
00031 /*! \file ezgzipshellcompressionhandler.php
00032 */
00033 
00034 /*!
00035   \class eZGZIPShellCompressionHandler ezgzipshellcompressionhandler.php
00036   \brief Handles files compressed with gzip using the shell commands
00037 
00038   Handles GZIP compression by executing the 'gzip' executable,
00039   without this the handler cannot work.
00040 
00041 NOTE: This is not done yet.
00042 */
00043 
00044 //include_once( 'lib/ezfile/classes/ezcompressionhandler.php' );
00045 
00046 class eZGZIPShellCompressionHandler extends eZCompressionHandler
00047 {
00048     /*!
00049     */
00050     function eZGZIPShellCompressionHandler()
00051     {
00052         $this->File = false;
00053         $thus->Level = false;
00054         $this->eZCompressionHandler( 'GZIP (shell)', 'gzipshell' );
00055     }
00056 
00057     /*!
00058      Sets the current compression level.
00059     */
00060     function setCompressionLevel( $level )
00061     {
00062         if ( $level < 0 or $level > 9 )
00063             $level = false;
00064         $this->Level = $level;
00065     }
00066 
00067     /*!
00068      \return the current compression level which is a number between 0 and 9,
00069              or \c false if the default is to be used.
00070     */
00071     function compressionLevel()
00072     {
00073         return $this->Level;
00074     }
00075 
00076     /*!
00077      \return true if this handler can be used.
00078     */
00079     static function isAvailable()
00080     {
00081         return false;
00082     }
00083 
00084     function gunzipFile( $filename )
00085     {
00086         $command = 'gzip -dc $filename > $';
00087     }
00088 
00089     /*!
00090      \reimp
00091     */
00092     function doOpen( $filename, $mode )
00093     {
00094         $this->File = @gzopen( $filename, $mode );
00095     }
00096 
00097     /*!
00098      \reimp
00099     */
00100     function doClose()
00101     {
00102         return @gzclose( $this->File );
00103     }
00104 
00105     /*!
00106      \reimp
00107     */
00108     function doRead( $uncompressedLength = false )
00109     {
00110         return @gzread( $this->File, $uncompressedLength );
00111     }
00112 
00113     /*!
00114      \reimp
00115     */
00116     function doWrite( $data, $uncompressedLength = false )
00117     {
00118         return @gzwrite( $this->File, $uncompressedLength );
00119     }
00120 
00121     /*!
00122      \reimp
00123     */
00124     function doFlush()
00125     {
00126         return @fflush( $this->File );
00127     }
00128 
00129     /*!
00130      \reimp
00131     */
00132     function doSeek( $offset, $whence )
00133     {
00134         if ( $whence == SEEK_SET )
00135             $offset = $offset - gztell( $this->File );
00136         else if ( $whence == SEEK_END )
00137         {
00138             eZDebugSetting::writeError( 'lib-ezfile-gziplibz',
00139                                         "Seeking from end is not supported for gzipped files" );
00140             return false;
00141         }
00142         return @gzseek( $this->File, $offset );
00143     }
00144 
00145     /*!
00146      \reimp
00147     */
00148     function doRewind()
00149     {
00150         return @gzrewind( $this->File );
00151     }
00152 
00153     /*!
00154      \reimp
00155     */
00156     function doTell()
00157     {
00158         return @gztell( $this->File );
00159     }
00160 
00161     /*!
00162      \reimp
00163     */
00164     function doEOF()
00165     {
00166         return @gzeof( $this->File );
00167     }
00168 
00169     /*!
00170      \reimp
00171     */
00172     function doPasstrough( $closeFile = true )
00173     {
00174         return @gzpasstru( $this->File );
00175     }
00176 
00177     /*!
00178      \reimp
00179     */
00180     function compress( $source )
00181     {
00182         return @gzcompress( $source, $this->Level );
00183     }
00184 
00185     /*!
00186      \reimp
00187     */
00188     function decompress( $source )
00189     {
00190         return @gzuncompress( $source );
00191     }
00192 
00193     /*!
00194      \reimp
00195     */
00196     function errorString()
00197     {
00198         return false;
00199     }
00200 
00201     /*!
00202      \reimp
00203     */
00204     function errorNumber()
00205     {
00206         return false;
00207     }
00208 
00209     /// \privatesection
00210     /// File pointer, returned by gzopen
00211     public $File;
00212     /// The compression level
00213     public $Level;
00214 }
00215 
00216 ?>