W3cubDocs

/Drupal 8

public function LocalStream::mkdir

public LocalStream::mkdir($uri, $mode, $options)

Support for mkdir().

Parameters

string $uri: A string containing the URI to the directory to create.

int $mode: Permission flags - see mkdir().

int $options: A bit mask of STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE.

Return value

bool TRUE if directory was successfully created.

Overrides PhpStreamWrapperInterface::mkdir

See also

http://php.net/manual/streamwrapper.mkdir.php

File

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

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);
  }
  if ($options & STREAM_REPORT_ERRORS) {
    return drupal_mkdir($localpath, $mode, $recursive);
  }
  else {
    return @drupal_mkdir($localpath, $mode, $recursive);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!StreamWrapper!LocalStream.php/function/LocalStream::mkdir/8.1.x