Exemple #1
0
 /**
  * Pack file by BZIP2 compressor.
  *
  * @param string $source
  * @param string $destination
  * @return string
  */
 public function pack($source, $destination)
 {
     $fileReader = new Mage_Archive_Helper_File($source);
     $fileReader->open('r');
     $archiveWriter = new Mage_Archive_Helper_File_Bz($destination);
     $archiveWriter->open('w');
     while (!$fileReader->eof()) {
         $archiveWriter->write($fileReader->read());
     }
     $fileReader->close();
     $archiveWriter->close();
     return $destination;
 }
Exemple #2
0
 /**
  * Write current file to tarball
  */
 protected function _packAndWriteCurrentFile()
 {
     $archiveWriter = $this->_getWriter();
     $archiveWriter->write($this->_composeHeader());
     $currentFile = $this->_getCurrentFile();
     $fileSize = 0;
     if (is_file($currentFile) && !is_link($currentFile)) {
         $fileReader = new Mage_Archive_Helper_File($currentFile);
         $fileReader->open('r');
         while (!$fileReader->eof()) {
             $archiveWriter->write($fileReader->read());
         }
         $fileReader->close();
         $fileSize = filesize($currentFile);
     }
     $appendZerosCount = (self::TAR_BLOCK_SIZE - $fileSize % self::TAR_BLOCK_SIZE) % self::TAR_BLOCK_SIZE;
     $archiveWriter->write(str_repeat("", $appendZerosCount));
 }