You are here

public function ResourceStreamWrapper::stream_open in D7 Media 6

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

Parameters

$path: A string containing the path 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

TRUE if file was opened successfully.

Overrides StreamWrapperInterface::stream_open

File

resource/ResourceStreamWrapper.inc, line 104

Class

ResourceStreamWrapper
A base class for Resource Stream Wrappers.

Code

public function stream_open($url, $mode, $options, &$opened_url) {
  resource_debug("stream open: {$url}");
  $url = $this
    ->interpolateUrl($url);
  $this->handle = $options & STREAM_REPORT_ERRORS ? fopen($url, $mode) : @fopen($url, $mode);
  if ((bool) $this->handle && $options & STREAM_USE_PATH) {
    $opened_url = $url;
  }
  resource_debug("stream opened: {$this->handle}");
  return (bool) $this->handle;
}