| [ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/file/unpacker/baseunpacker.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/file/unpacker/pclzip.lib.php" ); 5 6 /** 7 * \ingroup File_Unpacker 8 * 9 * unpacks files with ZIP. It can also use native PHP code with the 10 * PclZip library, set "unzip_use_native_version" to true if the configuration table 11 * for enabling that option. 12 * 13 * It users the binary "zip" to unpack the files. Its location is obtained from the 14 * config parameter "path_to_unzip" or /usr/bin/unzip if it does not exist 15 * 16 * @see Unpacker 17 * @see BaseUnpacker 18 */ 19 class ZipUnpacker extends BaseUnpacker 20 { 21 22 function ZipUnpacker() 23 { 24 $this->BaseUnpacker(); 25 } 26 27 /** 28 * uses a native php library that is capable of dealing with .zip 29 * files without needing to call external commands 30 * 31 * @param file 32 * @param destFolder 33 * @return true if successful or false otherwise 34 */ 35 function unpackNative( $file, $destFolder ) 36 { 37 $z = new PclZip($file); 38 return $z->extract( $destFolder ); 39 } 40 41 /** 42 * @see BaseUnpacker::unpack() 43 */ 44 function unpack( $file, $destFolder ) 45 { 46 // get the paths where tar and gz are 47 $config =& Config::getConfig(); 48 49 if( $config->getValue( "unzip_use_native_version" )) { 50 return $this->unpackNative( $file, $destFolder ); 51 } 52 else { 53 $unzipPath = $config->getValue( "path_to_unzip" ); 54 if( $unzipPath == "" ) 55 $unzipPath = DEFAULT_UNZIP_PATH; 56 57 $cmd = "$unzipPath -o $file -d $destFolder"; 58 59 $result = exec( $cmd, $output, $retval ); 60 61 // 62 // :KLUDGE: 63 // apparently, we should get something in $retval but there's nothing 64 // to the only way I've found to check if the command finished 65 // successfully was checking if the $output array is full or empty 66 // 67 68 return ( $retval == 0 ); 69 } 70 } 71 } 72 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
|