1.20.x stream_wrappers.inc public BackdropLocalStreamWrapper::stream_open($uri, $mode, $options, &$opened_path)

Support for fopen(), file_get_contents(), file_put_contents() etc.

Parameters

$uri: A string containing the URI to the file to open.

$mode: The file mode ("r", "wb" etc.).

$options: A bit mask of STREAM_USE_PATH and STREAM_REPORT_ERRORS.

$opened_path: A string containing the path actually opened.

Return value

Returns TRUE if file was opened successfully.:

Overrides StreamWrapperInterface::stream_open

See also

http://php.net/manual/streamwrapper.stream-open.php

File

includes/stream_wrappers.inc, line 404
Backdrop stream wrapper interface.

Class

BackdropLocalStreamWrapper
Backdrop stream wrapper base class for local files.

Code

public function stream_open($uri, $mode, $options, &$opened_path) {
  $this->uri = $uri;
  $path = $this->getLocalPath();
  if ($path) {
    $this->handle = ($options & STREAM_REPORT_ERRORS) ? fopen($path, $mode) : @fopen($path, $mode);
  }
  else {
    $this->handle = NULL;
  }

  if ((bool) $this->handle && $options & STREAM_USE_PATH) {
    $opened_path = $path;
  }

  return (bool) $this->handle;
}