You are here

public function vfsStreamWrapper::mkdir in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php \org\bovigo\vfs\vfsStreamWrapper::mkdir()

creates a new directory

Parameters

string $path:

int $mode:

int $options:

Return value

bool

1 call to vfsStreamWrapper::mkdir()
vfsStreamWrapperRecordingProxy::mkdir in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/proxy/vfsStreamWrapperRecordingProxy.php
creates a new directory
1 method overrides vfsStreamWrapper::mkdir()
vfsStreamWrapperRecordingProxy::mkdir in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/proxy/vfsStreamWrapperRecordingProxy.php
creates a new directory

File

vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php, line 833

Class

vfsStreamWrapper
Stream wrapper to mock file system requests.

Namespace

org\bovigo\vfs

Code

public function mkdir($path, $mode, $options) {
  $umask = vfsStream::umask();
  if (0 < $umask) {
    $permissions = $mode & ~$umask;
  }
  else {
    $permissions = $mode;
  }
  $path = $this
    ->resolvePath(vfsStream::path($path));
  if (null !== $this
    ->getContent($path)) {
    trigger_error('mkdir(): Path vfs://' . $path . ' exists', E_USER_WARNING);
    return false;
  }
  if (null === self::$root) {
    self::$root = vfsStream::newDirectory($path, $permissions);
    return true;
  }
  $maxDepth = count(explode('/', $path));
  $names = $this
    ->splitPath($path);
  $newDirs = $names['basename'];
  $dir = null;
  $i = 0;
  while ($dir === null && $i < $maxDepth) {
    $dir = $this
      ->getContent($names['dirname']);
    $names = $this
      ->splitPath($names['dirname']);
    if (null == $dir) {
      $newDirs = $names['basename'] . '/' . $newDirs;
    }
    $i++;
  }
  if (null === $dir || $dir
    ->getType() !== vfsStreamContent::TYPE_DIR || $dir
    ->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
    return false;
  }
  $recursive = (STREAM_MKDIR_RECURSIVE & $options) !== 0 ? true : false;
  if (strpos($newDirs, '/') !== false && false === $recursive) {
    return false;
  }
  vfsStream::newDirectory($newDirs, $permissions)
    ->at($dir);
  return true;
}