32 if ($stream->isReadable()) {
33 $mode = $stream->isWritable() ?
'r+' :
'r';
34 } elseif ($stream->isWritable()) {
37 throw new \InvalidArgumentException(
'The stream must be readable, '
38 .
'writable, or both.');
41 return fopen(
'guzzle://stream', $mode,
null, self::createStreamContext($stream));
53 return stream_context_create([
54 'guzzle' => [
'stream' => $stream]
61 public static function register()
63 if (!in_array(
'guzzle', stream_get_wrappers())) {
64 stream_wrapper_register(
'guzzle', __CLASS__);
68 public function stream_open($path, $mode, $options, &$opened_path)
70 $options = stream_context_get_options($this->context);
72 if (!isset($options[
'guzzle'][
'stream'])) {
77 $this->stream = $options[
'guzzle'][
'stream'];
84 return $this->stream->read($count);
89 return (
int) $this->stream->write($data);
94 return $this->stream->tell();
99 return $this->stream->eof();
104 $this->stream->seek($offset, $whence);
111 $stream = clone($this->stream);
113 return $stream->detach();
129 'mode' => $modeMap[$this->mode],
134 'size' => $this->stream->getSize() ?: 0,
143 public function url_stat($path, $flags)