Пример #1
0
 /**
  * Open stream
  */
 public function stream_open($path, $mode, $options, &$opened_path)
 {
     // Check for mode
     if ($mode[0] != 'r') {
         throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
     }
     // Parse URL
     $url = @parse_url($path);
     // Fix URL
     if (!is_array($url)) {
         $url['host'] = substr($path, strlen('zip://'));
         $url['path'] = '';
     }
     if (strpos($url['host'], '#') !== false) {
         if (!isset($url['fragment'])) {
             $url['fragment'] = substr($url['host'], strpos($url['host'], '#') + 1) . $url['path'];
             $url['host'] = substr($url['host'], 0, strpos($url['host'], '#'));
             unset($url['path']);
         }
     } else {
         $url['host'] = $url['host'] . $url['path'];
         unset($url['path']);
     }
     // 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;
 }
 /**
  * Open stream
  */
 public function stream_open($path, $mode, $options, &$opened_path)
 {
     // Check for mode
     if ($mode[0] != 'r') {
         throw new 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;
 }