Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. vfsStreamWrapper.php

function vfsStreamWrapper::mkdir

creates a new directory

Parameters

string $path:

int $mode:

int $options:

Return value

bool

File

vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php, line 839

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal