|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZArchiveHandler class 00004 // 00005 // Created on: <14-Aug-2003 11:25:33 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 ezarchivehandler.php 00032 */ 00033 00034 /*! 00035 \class eZArchiveHandler ezarchivehandler.php 00036 \brief General handling of file archives 00037 00038 This class handles the abstraction of handling various 00039 kinds of archive formats. The actual handling of the 00040 formats is sent of the specific archive handlers. 00041 00042 \code 00043 $handler = eZArchiveHandler::instance( 'tar', 'ezpublish.tar' ); 00044 \endcode 00045 00046 */ 00047 00048 //include_once( 'lib/ezfile/classes/ezfilehandler.php' ); 00049 00050 class eZArchiveHandler 00051 { 00052 /*! 00053 Constructor 00054 */ 00055 function eZArchiveHandler( $fileHandler, $archiveFilename = false ) 00056 { 00057 $this->FileHandler = $fileHandler; 00058 $this->ArchiveFilename = $archiveFilename; 00059 } 00060 00061 function setArchiveFileName( $filename ) 00062 { 00063 $this->ArchiveFilename = $filename; 00064 } 00065 00066 function fileIsOpen() 00067 { 00068 return $this->FileHandler->isOpen(); 00069 } 00070 00071 function fileIsBinaryMode() 00072 { 00073 return $this->FileHandler->isBinaryMode(); 00074 } 00075 00076 function fileName() 00077 { 00078 return $this->FileHandler->filename(); 00079 } 00080 00081 function fileMode() 00082 { 00083 return $this->FileHandler->mode(); 00084 } 00085 00086 function fileOpen( $archiveFilename = false, $mode = false ) 00087 { 00088 if ( !$archiveFilename ) 00089 $archiveFilename = $this->ArchiveFilename; 00090 $result = $this->FileHandler->open( $archiveFilename, $mode ); 00091 if ( $result ) 00092 $this->ArchiveFilename = $archiveFilename; 00093 return $result; 00094 } 00095 00096 function fileClose() 00097 { 00098 return $this->FileHandler->close(); 00099 } 00100 00101 function fileRead( $length = false ) 00102 { 00103 return $this->FileHandler->read( $length ); 00104 } 00105 00106 function fileWrite( $data, $length = false ) 00107 { 00108 return $this->FileHandler->write( $data, $length ); 00109 } 00110 00111 function fileFlush() 00112 { 00113 return $this->FileHandler->flush(); 00114 } 00115 00116 function fileSeek( $offset, $whence = SEEK_SET ) 00117 { 00118 return $this->FileHandler->seek( $offset, $whence ); 00119 } 00120 00121 function fileRewind() 00122 { 00123 return $this->FileHandler->rewind(); 00124 } 00125 00126 function fileTell() 00127 { 00128 return $this->FileHandler->tell(); 00129 } 00130 00131 function fileEOF() 00132 { 00133 return $this->FileHandler->eof(); 00134 } 00135 00136 function filePasstrough( $closeFile = true ) 00137 { 00138 return $this->FileHandler->passtrough( $closeFile ); 00139 } 00140 00141 function fileError() 00142 { 00143 return $this->FileHandler->error(); 00144 } 00145 00146 function fileErrorString() 00147 { 00148 return $this->FileHandler->errorString(); 00149 } 00150 00151 function fileErrorNumber() 00152 { 00153 return $this->FileHandler->errorNumber(); 00154 } 00155 00156 /*! 00157 Calls the rename() function for the current handler. 00158 */ 00159 function fileRename( $destinationFilename, $sourceFilename = true ) 00160 { 00161 return $this->FileHandler->rename( $destinationFilename, $sourceFilename ); 00162 } 00163 00164 function fileUnlink( $filename = false ) 00165 { 00166 return $this->FileHandler->unlink( $filename ); 00167 } 00168 00169 function fileCopy( $sourceFilename, $destinationFilename ) 00170 { 00171 return $this->FileHandler->copy( $sourceFilename, $destinationFilename ); 00172 } 00173 00174 function fileExists( $filename = false ) 00175 { 00176 return $this->FileHandler->exists( $filename ); 00177 } 00178 00179 function fileIsDirectory( $filename = false ) 00180 { 00181 return $this->FileHandler->isDirectory( $filename ); 00182 } 00183 00184 function fileIsExecutable( $filename = false ) 00185 { 00186 return $this->FileHandler->isExecutable( $filename ); 00187 } 00188 00189 function fileIsFile( $filename = false ) 00190 { 00191 return $this->FileHandler->isFile( $filename ); 00192 } 00193 00194 function fileIsLink( $filename = false ) 00195 { 00196 return $this->FileHandler->isLink( $filename ); 00197 } 00198 00199 function fileIsReadable( $filename = false ) 00200 { 00201 return $this->FileHandler->isReadable( $filename ); 00202 } 00203 00204 function fileIsWriteable( $filename = false ) 00205 { 00206 return $this->FileHandler->isWriteable( $filename ); 00207 } 00208 00209 function fileStatistics( $filename = false ) 00210 { 00211 return $this->FileHandler->statistics( $filename ); 00212 } 00213 00214 /*! 00215 \return the current file handler used for opening the archive file. 00216 */ 00217 function fileHandler() 00218 { 00219 return $this->FileHandler; 00220 } 00221 00222 /*! 00223 \return \c true if the handler is available for use. 00224 */ 00225 function isAvailable() 00226 { 00227 return true; 00228 } 00229 00230 /*! 00231 Detaches the current file handler and instanties a new duplicate as current. 00232 \return the old file handler. 00233 */ 00234 function &detachHandler() 00235 { 00236 $oldHandler = $this->FileHandler; 00237 $this->FileHandler = $oldHandler->duplicate(); 00238 return $oldHandler; 00239 } 00240 00241 /*! 00242 Returns the handler for the identifier \a $identifier. 00243 The parameter \a $fileHandler must contain the filehandler object. 00244 \return \c false if the handler could not be created. 00245 */ 00246 static function instance( $identifier, $fileHandlerType = false, $arhiveFilename = false ) 00247 { 00248 //include_once( 'lib/ezutils/classes/ezini.php' ); 00249 $ini = eZINI::instance( 'file.ini' ); 00250 $handlers = $ini->variable( 'ArchiveSettings', 'Handlers' ); 00251 $instance = false; 00252 if ( isset( $handlers[$identifier] ) ) 00253 { 00254 $className = $handlers[$identifier]; 00255 $includeFile = 'lib/ezfile/classes/' . $className . '.php'; 00256 include_once( $includeFile ); 00257 $fileHandler = eZFileHandler::instance( $fileHandlerType ); 00258 $instance = new $className( $fileHandler, $arhiveFilename ); 00259 if ( !$instance->isAvailable() ) 00260 { 00261 unset( $instance ); 00262 $instance = false; 00263 } 00264 } 00265 return $instance; 00266 } 00267 00268 /// \privatesection 00269 public $FileHandler; 00270 } 00271 00272 ?>