示例#1
0
 /**
  * Destroy tarball reader
  *
  * @return \Magento\Framework\Archive\Tar
  */
 protected function _destroyReader()
 {
     if ($this->_reader instanceof \Magento\Framework\Archive\Helper\File) {
         $this->_reader->close();
         $this->_reader = null;
     }
     return $this;
 }
示例#2
0
文件: Tar.php 项目: nja78/magento2
 /**
  * Extract next file from tarball by its $header information and save it to $destination
  *
  * @param array $fileHeader
  * @param string $destination
  * @return void
  */
 protected function _extractAndWriteFile($fileHeader, $destination)
 {
     $fileWriter = new 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);
     }
 }