10 defined(
'JPATH_PLATFORM') or die;
46 public $buffers = array();
62 public function stream_open($path, $mode, $options, &$opened_path)
64 $url = parse_url($path);
65 $this->name = $url[
'host'];
66 $this->buffers[$this->name] = null;
84 public function stream_read($count)
86 $ret = substr($this->buffers[$this->name], $this->position, $count);
87 $this->position += strlen($ret);
102 public function stream_write($data)
104 $left = substr($this->buffers[$this->name], 0, $this->position);
105 $right = substr($this->buffers[$this->name], $this->position + strlen($data));
106 $this->buffers[$this->name] = $left . $data . $right;
107 $this->position += strlen($data);
109 return strlen($data);
120 public function stream_tell()
122 return $this->position;
133 public function stream_eof()
135 return $this->position >= strlen($this->buffers[$this->name]);
150 public function stream_seek($offset, $whence)
155 if ($offset < strlen($this->buffers[$this->name]) && $offset >= 0)
157 $this->position = $offset;
170 $this->position += $offset;
181 if (strlen($this->buffers[$this->name]) + $offset >= 0)
183 $this->position = strlen($this->buffers[$this->name]) + $offset;
199 stream_wrapper_register(
'buffer',
'JBuffer');