function LocalStream::stream_open

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/StreamWrapper/LocalStream.php \Drupal\Core\StreamWrapper\LocalStream::stream_open()
  2. 10 core/lib/Drupal/Core/StreamWrapper/LocalStream.php \Drupal\Core\StreamWrapper\LocalStream::stream_open()
  3. 8.9.x core/lib/Drupal/Core/StreamWrapper/LocalStream.php \Drupal\Core\StreamWrapper\LocalStream::stream_open()

File

core/lib/Drupal/Core/StreamWrapper/LocalStream.php, line 147

Class

LocalStream
Defines a Drupal stream wrapper base class for local files.

Namespace

Drupal\Core\StreamWrapper

Code

public function stream_open($uri, $mode, $options, &$opened_path) {
  $this->uri = $uri;
  $path = $this->getLocalPath();
  if ($path === FALSE) {
    if ($options & STREAM_REPORT_ERRORS) {
      trigger_error('stream_open() filename cannot be empty', E_USER_WARNING);
    }
    return FALSE;
  }
  $this->handle = $options & STREAM_REPORT_ERRORS ? fopen($path, $mode) : @fopen($path, $mode);
  if ((bool) $this->handle && $options & STREAM_USE_PATH) {
    $opened_path = $path;
  }
  return (bool) $this->handle;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.