org\bovigo\vfs\vfsStreamWrapper::mkdir PHP Method

mkdir() public method

creates a new directory
public mkdir ( string $path, integer $mode, integer $options ) : boolean
$path string
$mode integer
$options integer
return boolean
    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;
    }