You are here

public function PHPExcel_Shared_ZipStreamWrapper::stream_open in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/ZipStreamWrapper.php \PHPExcel_Shared_ZipStreamWrapper::stream_open()

* Implements support for fopen(). * *

Parameters

string $path resource name including scheme, e.g.: * @param string $mode only "r" is supported * @param int $options mask of STREAM_REPORT_ERRORS and STREAM_USE_PATH * @param string &$openedPath absolute path of the opened stream (out parameter) * @return bool true on success

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/ZipStreamWrapper.php, line 82

Class

PHPExcel_Shared_ZipStreamWrapper
PHPExcel_Shared_ZipStreamWrapper

Code

public function stream_open($path, $mode, $options, &$opened_path) {

  // Check for mode
  if ($mode[0] != 'r') {
    throw new PHPExcel_Reader_Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
  }
  $pos = strrpos($path, '#');
  $url['host'] = substr($path, 6, $pos - 6);

  // 6: strlen('zip://')
  $url['fragment'] = substr($path, $pos + 1);

  // Open archive
  $this->_archive = new ZipArchive();
  $this->_archive
    ->open($url['host']);
  $this->_fileNameInArchive = $url['fragment'];
  $this->_position = 0;
  $this->_data = $this->_archive
    ->getFromName($this->_fileNameInArchive);
  return true;
}