コード例 #1
0
ファイル: Bz.php プロジェクト: cewolf2002/magento
 /**
  * Unpack file by BZIP2 compressor.
  *
  * @param string $source
  * @param string $destination
  * @return string
  */
 public function unpack($source, $destination)
 {
     if (is_dir($destination)) {
         $file = $this->getFilename($source);
         $destination = $destination . $file;
     }
     $archiveReader = new Mage_Archive_Helper_File_Bz($source);
     $archiveReader->open('r');
     $fileWriter = new Mage_Archive_Helper_File($destination);
     $fileWriter->open('w');
     while (!$archiveReader->eof()) {
         $fileWriter->write($archiveReader->read());
     }
     return $destination;
 }
コード例 #2
0
ファイル: Gz.php プロジェクト: cewolf2002/magento
 /**
  * Overwritten Mage_Archive_Helper_File constructor with zlib extension check
  * @param string $filePath
  * @throws Mage_Exception
  */
 public function __construct($filePath)
 {
     if (!function_exists('gzopen')) {
         throw new Mage_Exception('PHP Extensions "zlib" must be loaded.');
     }
     parent::__construct($filePath);
 }
コード例 #3
0
ファイル: Tar.php プロジェクト: chucky515/Magento-CE-Mirror
 /**
  * Extract next file from tarball by its $header information and save it to $destination
  *
  * @param array $fileHeader
  * @param string $destination
  */
 protected function _extractAndWriteFile($fileHeader, $destination)
 {
     $fileWriter = new Mage_Archive_Helper_File($destination);
     $fileWriter->open('w', $fileHeader['mode']);
     $archiveReader = $this->_getReader();
     $filesize = $fileHeader['size'];
     $bytesExtracted = 0;
     while ($filesize > $bytesExtracted && !$archiveReader->eof()) {
         $block = $archiveReader->read(self::TAR_BLOCK_SIZE);
         $nonExtractedBytesCount = $filesize - $bytesExtracted;
         $data = substr($block, 0, $nonExtractedBytesCount);
         $fileWriter->write($data);
         $bytesExtracted += strlen($block);
     }
 }