Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

(no description)

File Size: 330 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

StreamWrapper:: (15 methods):
  __destruct()
  getFile()
  register()
  stream_close()
  stream_eof()
  stream_open()
  stream_read()
  stream_seek()
  stream_stat()
  stream_tell()
  stream_write()
  getStatTemplate()
  initProtocol()
  initReadableStream()
  initWritableStream()


Class: StreamWrapper  - X-Ref

Stream wrapper for reading and writing a GridFS file.

__destruct()   X-Ref
No description

getFile()   X-Ref
Return the stream's file document.


register(string $protocol = 'gridfs')   X-Ref
Register the GridFS stream wrapper.

param: string $protocol Protocol to use for stream_wrapper_register()

stream_close()   X-Ref
Closes the stream.


stream_eof()   X-Ref
Returns whether the file pointer is at the end of the stream.


stream_open(string $path, string $mode, int $options, ?string &$openedPath)   X-Ref
Opens the stream.

param: string      $path       Path to the file resource
param: string      $mode       Mode used to open the file (only "r" and "w" are supported)
param: integer     $options    Additional flags set by the streams API
param: string|null $openedPath Not used

stream_read(int $length)   X-Ref
Read bytes from the stream.

Note: this method may return a string smaller than the requested length
if data is not available to be read.

param: integer $length Number of bytes to read

stream_seek(int $offset, int $whence = SEEK_SET)   X-Ref
Return the current position of the stream.

param: integer $offset Stream offset to seek to
param: integer $whence One of SEEK_SET, SEEK_CUR, or SEEK_END
return: boolean True if the position was updated and false otherwise

stream_stat()   X-Ref
Return information about the stream.


stream_tell()   X-Ref
Return the current position of the stream.

return: integer The current position of the stream

stream_write(string $data)   X-Ref
Write bytes to the stream.

param: string $data Data to write
return: integer The number of bytes written

getStatTemplate()   X-Ref
Returns a stat template with default values.


initProtocol(string $path)   X-Ref
Initialize the protocol from the given path.


initReadableStream()   X-Ref
Initialize the internal stream for reading.


initWritableStream()   X-Ref
Initialize the internal stream for writing.