You are here

public function LocalStream::mkdir in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/StreamWrapper/LocalStream.php \Drupal\Core\StreamWrapper\LocalStream::mkdir()
  2. 9 core/lib/Drupal/Core/StreamWrapper/LocalStream.php \Drupal\Core\StreamWrapper\LocalStream::mkdir()

File

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

Class

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

Namespace

Drupal\Core\StreamWrapper

Code

public function mkdir($uri, $mode, $options) {
  $this->uri = $uri;
  $recursive = (bool) ($options & STREAM_MKDIR_RECURSIVE);
  if ($recursive) {

    // $this->getLocalPath() fails if $uri has multiple levels of directories
    // that do not yet exist.
    $localpath = $this
      ->getDirectoryPath() . '/' . $this
      ->getTarget($uri);
  }
  else {
    $localpath = $this
      ->getLocalPath($uri);
  }

  /** @var \Drupal\Core\File\FileSystemInterface $file_system */
  $file_system = \Drupal::service('file_system');
  if ($options & STREAM_REPORT_ERRORS) {
    return $file_system
      ->mkdir($localpath, $mode, $recursive);
  }
  else {
    return @$file_system
      ->mkdir($localpath, $mode, $recursive);
  }
}