Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 39... Línea 39...
39
            $mode = $stream->isWritable() ? 'r+' : 'r';
39
            $mode = $stream->isWritable() ? 'r+' : 'r';
40
        } elseif ($stream->isWritable()) {
40
        } elseif ($stream->isWritable()) {
41
            $mode = 'w';
41
            $mode = 'w';
42
        } else {
42
        } else {
43
            throw new \InvalidArgumentException('The stream must be readable, '
43
            throw new \InvalidArgumentException('The stream must be readable, '
44
                . 'writable, or both.');
44
                .'writable, or both.');
45
        }
45
        }
Línea 46... Línea 46...
46
 
46
 
47
        return fopen('guzzle://stream', $mode, false, self::createStreamContext($stream));
47
        return fopen('guzzle://stream', $mode, false, self::createStreamContext($stream));
Línea 53... Línea 53...
53
     * @return resource
53
     * @return resource
54
     */
54
     */
55
    public static function createStreamContext(StreamInterface $stream)
55
    public static function createStreamContext(StreamInterface $stream)
56
    {
56
    {
57
        return stream_context_create([
57
        return stream_context_create([
58
            'guzzle' => ['stream' => $stream]
58
            'guzzle' => ['stream' => $stream],
59
        ]);
59
        ]);
60
    }
60
    }
Línea 61... Línea 61...
61
 
61
 
62
    /**
62
    /**
Línea 67... Línea 67...
67
        if (!in_array('guzzle', stream_get_wrappers())) {
67
        if (!in_array('guzzle', stream_get_wrappers())) {
68
            stream_wrapper_register('guzzle', __CLASS__);
68
            stream_wrapper_register('guzzle', __CLASS__);
69
        }
69
        }
70
    }
70
    }
Línea 71... Línea 71...
71
 
71
 
72
    public function stream_open(string $path, string $mode, int $options, string &$opened_path = null): bool
72
    public function stream_open(string $path, string $mode, int $options, ?string &$opened_path = null): bool
73
    {
73
    {
Línea 74... Línea 74...
74
        $options = stream_context_get_options($this->context);
74
        $options = stream_context_get_options($this->context);
75
 
75
 
Línea 113... Línea 113...
113
    /**
113
    /**
114
     * @return resource|false
114
     * @return resource|false
115
     */
115
     */
116
    public function stream_cast(int $cast_as)
116
    public function stream_cast(int $cast_as)
117
    {
117
    {
118
        $stream = clone($this->stream);
118
        $stream = clone $this->stream;
119
        $resource = $stream->detach();
119
        $resource = $stream->detach();
Línea 120... Línea 120...
120
 
120
 
121
        return $resource ?? false;
121
        return $resource ?? false;
Línea 122... Línea 122...
122
    }
122
    }
123
 
123
 
-
 
124
    /**
-
 
125
     * @return array{
-
 
126
     *   dev: int,
-
 
127
     *   ino: int,
-
 
128
     *   mode: int,
-
 
129
     *   nlink: int,
-
 
130
     *   uid: int,
-
 
131
     *   gid: int,
-
 
132
     *   rdev: int,
-
 
133
     *   size: int,
-
 
134
     *   atime: int,
-
 
135
     *   mtime: int,
-
 
136
     *   ctime: int,
-
 
137
     *   blksize: int,
124
    /**
138
     *   blocks: int
125
     * @return array<int|string, int>
139
     * }|false
126
     */
140
     */
-
 
141
    public function stream_stat()
-
 
142
    {
-
 
143
        if ($this->stream->getSize() === null) {
-
 
144
            return false;
127
    public function stream_stat(): array
145
        }
128
    {
146
 
129
        static $modeMap = [
147
        static $modeMap = [
130
            'r'  => 33060,
148
            'r' => 33060,
131
            'rb' => 33060,
149
            'rb' => 33060,
132
            'r+' => 33206,
150
            'r+' => 33206,
133
            'w'  => 33188,
151
            'w' => 33188,
Línea 134... Línea 152...
134
            'wb' => 33188
152
            'wb' => 33188,
135
        ];
153
        ];
136
 
154
 
137
        return [
155
        return [
138
            'dev'     => 0,
156
            'dev' => 0,
139
            'ino'     => 0,
157
            'ino' => 0,
140
            'mode'    => $modeMap[$this->mode],
158
            'mode' => $modeMap[$this->mode],
141
            'nlink'   => 0,
159
            'nlink' => 0,
142
            'uid'     => 0,
160
            'uid' => 0,
143
            'gid'     => 0,
161
            'gid' => 0,
144
            'rdev'    => 0,
162
            'rdev' => 0,
145
            'size'    => $this->stream->getSize() ?: 0,
163
            'size' => $this->stream->getSize() ?: 0,
146
            'atime'   => 0,
164
            'atime' => 0,
147
            'mtime'   => 0,
165
            'mtime' => 0,
148
            'ctime'   => 0,
166
            'ctime' => 0,
149
            'blksize' => 0,
167
            'blksize' => 0,
Línea 150... Línea 168...
150
            'blocks'  => 0
168
            'blocks' => 0,
151
        ];
169
        ];
-
 
170
    }
-
 
171
 
-
 
172
    /**
-
 
173
     * @return array{
-
 
174
     *   dev: int,
-
 
175
     *   ino: int,
-
 
176
     *   mode: int,
-
 
177
     *   nlink: int,
-
 
178
     *   uid: int,
-
 
179
     *   gid: int,
-
 
180
     *   rdev: int,
-
 
181
     *   size: int,
-
 
182
     *   atime: int,
-
 
183
     *   mtime: int,
152
    }
184
     *   ctime: int,
153
 
185
     *   blksize: int,
154
    /**
186
     *   blocks: int
155
     * @return array<int|string, int>
187
     * }
156
     */
188
     */
157
    public function url_stat(string $path, int $flags): array
189
    public function url_stat(string $path, int $flags): array
158
    {
190
    {
159
        return [
191
        return [
160
            'dev'     => 0,
192
            'dev' => 0,
161
            'ino'     => 0,
193
            'ino' => 0,
162
            'mode'    => 0,
194
            'mode' => 0,
163
            'nlink'   => 0,
195
            'nlink' => 0,
164
            'uid'     => 0,
196
            'uid' => 0,
165
            'gid'     => 0,
197
            'gid' => 0,
166
            'rdev'    => 0,
198
            'rdev' => 0,
167
            'size'    => 0,
199
            'size' => 0,
168
            'atime'   => 0,
200
            'atime' => 0,
169
            'mtime'   => 0,
201
            'mtime' => 0,
170
            'ctime'   => 0,
202
            'ctime' => 0,
171
            'blksize' => 0,
203
            'blksize' => 0,