Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
StreamWrapper.php
001 <?php
002
003 namespace GuzzleHttp\Psr7;
004
005 use Psr\Http\Message\StreamInterface;
006
007 /**
008 * Converts Guzzle streams into PHP stream resources.
009 *
010 * @final
011 */
012 class StreamWrapper
013 {
014 /** @var resource */
015 public $context;
016
017 /** @var StreamInterface */
018 private $stream;
019
020 /** @var string r, r+, or w */
021 private $mode;
022
023 /**
024 * Returns a resource representing the stream.
025 *
026 * @param StreamInterface $stream The stream to get a resource for
027 *
028 * @return resource
029 *
030 * @throws \InvalidArgumentException if stream is not readable or writable
031 */
032 public static function getResource(StreamInterface $stream)
033 {
034 self::register();
035
036 if ($stream->isReadable()) {
037 $mode = $stream->isWritable() ? 'r+' : 'r';
038 } elseif ($stream->isWritable()) {
039 $mode = 'w';
040 } else {
041 throw new \InvalidArgumentException('The stream must be readable, '
042 . 'writable, or both.');
043 }
044
045 return fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
046 }
047
048 /**
049 * Creates a stream context that can be used to open a stream as a php stream resource.
050 *
051 * @param StreamInterface $stream
052 *
053 * @return resource
054 */
055 public static function createStreamContext(StreamInterface $stream)
056 {
057 return stream_context_create([
058 'guzzle' => ['stream' => $stream]
059 ]);
060 }
061
062 /**
063 * Registers the stream wrapper if needed
064 */
065 public static function register()
066 {
067 if (!in_array('guzzle', stream_get_wrappers())) {
068 stream_wrapper_register('guzzle', __CLASS__);
069 }
070 }
071
072 public function stream_open($path, $mode, $options, &$opened_path)
073 {
074 $options = stream_context_get_options($this->context);
075
076 if (!isset($options['guzzle']['stream'])) {
077 return false;
078 }
079
080 $this->mode = $mode;
081 $this->stream = $options['guzzle']['stream'];
082
083 return true;
084 }
085
086 public function stream_read($count)
087 {
088 return $this->stream->read($count);
089 }
090
091 public function stream_write($data)
092 {
093 return (int) $this->stream->write($data);
094 }
095
096 public function stream_tell()
097 {
098 return $this->stream->tell();
099 }
100
101 public function stream_eof()
102 {
103 return $this->stream->eof();
104 }
105
106 public function stream_seek($offset, $whence)
107 {
108 $this->stream->seek($offset, $whence);
109
110 return true;
111 }
112
113 public function stream_cast($cast_as)
114 {
115 $stream = clone($this->stream);
116
117 return $stream->detach();
118 }
119
120 public function stream_stat()
121 {
122 static $modeMap = [
123 'r' => 33060,
124 'rb' => 33060,
125 'r+' => 33206,
126 'w' => 33188,
127 'wb' => 33188
128 ];
129
130 return [
131 'dev' => 0,
132 'ino' => 0,
133 'mode' => $modeMap[$this->mode],
134 'nlink' => 0,
135 'uid' => 0,
136 'gid' => 0,
137 'rdev' => 0,
138 'size' => $this->stream->getSize() ?: 0,
139 'atime' => 0,
140 'mtime' => 0,
141 'ctime' => 0,
142 'blksize' => 0,
143 'blocks' => 0
144 ];
145 }
146
147 public function url_stat($path, $flags)
148 {
149 return [
150 'dev' => 0,
151 'ino' => 0,
152 'mode' => 0,
153 'nlink' => 0,
154 'uid' => 0,
155 'gid' => 0,
156 'rdev' => 0,
157 'size' => 0,
158 'atime' => 0,
159 'mtime' => 0,
160 'ctime' => 0,
161 'blksize' => 0,
162 'blocks' => 0
163 ];
164 }
165 }
166