72 public static function register() {
73 @stream_wrapper_unregister(
"zip");
74 @stream_wrapper_register(
"zip", __CLASS__);
80 public function stream_open($path, $mode, $options, &$opened_path) {
82 if ($mode{0} !=
'r') {
83 throw new Exception(
'Mode ' . $mode .
' is not supported. Only read mode is supported.');
87 $url = @parse_url($path);
90 if (!is_array($url)) {
91 $url[
'host'] = substr($path, strlen(
'zip://'));
94 if (strpos($url[
'host'],
'#') !==
false) {
95 if (!isset($url[
'fragment'])) {
96 $url[
'fragment'] = substr($url[
'host'], strpos($url[
'host'],
'#') + 1) . $url[
'path'];
97 $url[
'host'] = substr($url[
'host'], 0, strpos($url[
'host'],
'#'));
101 $url[
'host'] = $url[
'host'] . $url[
'path'];
106 $this->_archive =
new ZipArchive();
107 $this->_archive->open($url[
'host']);
109 $this->_fileNameInArchive = $url[
'fragment'];
110 $this->_position = 0;
111 $this->_data = $this->_archive->getFromName( $this->_fileNameInArchive );
120 return $this->_archive->statName( $this->_fileNameInArchive );
127 $ret = substr($this->_data, $this->_position, $count);
128 $this->_position += strlen(
$ret);
143 return $this->_position >= strlen($this->_data);
152 if ($offset < strlen($this->_data) && $offset >= 0) {
153 $this->_position = $offset;
162 $this->_position += $offset;
170 if (strlen($this->_data) + $offset >= 0) {
171 $this->_position = strlen($this->_data) + $offset;