Creates a directory.

@param  string $path      Path to directory
@param  int    $mode      Mode
@param  bool   $recursive Recursive
@return bool
504635
public function createDirectory(string $path, int $mode = 0777, bool $recursive = false): bool
	{
		return mkdir($path, $mode, $recursive);
	}
1294030
public function makeDirectory( $mode = NULL )
    {
        $mode = $mode ? $mode : 0777;

        if ( file_exists($this->path) ){
            if ( is_file($this->path) ){
                throw new MakeDirectoryException($this);
            }
            return;
        }

        $parent_dir = $this->getParent();

        if ( !$parent_dir->exists() ){
            $parent_dir->makeDirectory( $mode );
        }

        $res = @mkdir( $this->path, $mode );
        if ( $res === FALSE ){
            throw new MakeDirectoryException($this);
        }
    }
910377
public function mkdir($path, $mode = 0777, $recursive = false)
    {
        if (null !== $this->at($path)) {
            trigger_error("mkdir(): File exists");
            return false;
        }

        $parts = explode('/', $this->realpath($path));
        $filesCount = 0;
        $missing = [];
        $item = array_shift($parts);
        foreach ($parts as $part) {
            $item .= "/{$part}";
            $node = $this->at($item);
            if ($node === null) {
                $missing[] = $item;
            } else if ($node->type == 'file') {
                $filesCount ++;
            }
        }

        if ($filesCount > 0) {
            trigger_error("mkdir(): Not a directory");
            return false;
        }

        if (count($missing) > 1 && !$recursive) {
            trigger_error("mkdir(): No such file or directory");
            return false;
        }

        foreach ($missing as $path) {
            $this->at($path, (object) [
                'type' => 'dir',
                'perms' => $mode
            ]);
        }

        return true;
   }
715066
public function addDirectory($name, $mode = 0777) {
        if (is_null($name)) {
            return $this;
        }
        $dir = $this->getChild($name);
        if (!is_dir($dir)) {
            mkdir($dir, $mode);
        }
        return new Directory($dir);
    }
987615
public function create($filepath, $mode = "w")
    {
        //@1 Fopen cannot create directories,
        //so if trying to create a file in subfolders that don't exist will throw a warning
        //wewill first create these directories;
        $dirname = dirname($filepath);

        if (!is_dir($dirname)) {
            if (mkdir($dirname, 0755, true)) {
                return $dirname;
            } else {
                return false;
            }
        }

        //@2 Attempt to create the file
        if (!($file = $this->getFileStream($filepath, $mode))) {
            return false;
        }

        return $file;
    }
829659
private function createDir($path, $chmod = 0777, $recursive = true)
    {
        if (!mkdir($path, $chmod, $recursive)) {
            throw new RuntimeException(
                sprintf(
                    'The directory path "%s" could not be created.',
                    $path
                )
            );
        }
    }
1043606
public function mkDir($name, $recursive = null, $chmod = null)
    {
        // test the recursive mode with default value
        $recursive = ($recursive === null) ? $this->recursiveDirectories : $recursive;
        // test the chmod with default value
        $chmod = ($chmod === null) ? $this->defCHMOD : $chmod;
        if (!is_dir($name)) {
            return (mkdir($name)) ? true : false;
        }

        return false;
    }
700198
public static function createDir($dir, $mode = 0775)
    {
        if (empty($dir)) return false;
        if (!is_dir($dir)) {
            if(@mkdir($dir, $mode, true)){
                return true;
            }else{
                return false;
            }
        } else {
           return true;
        }
    }
915699
public function createFolder($path)
    {
        $mode = 0777;
        $recursive = true;
        $path = ltrim($path, "/");
        return mkdir($this->pathRoot.$path, $mode, $recursive);
    }
441289
public function make($mode = 0777) {
		if (!$this->exists() && !@mkdir($this->pathname, $mode, true)) {
			throw new FileException(sprintf('Failed to create directory "%s"', $this->pathname));
		}
	}
875502
public static function mkdir($path, $mode = 0755, $recursive = false, $force = false)
    {
        if (!self::exists($path)) {
            if ($force) {
                return @mkdir($path, $mode, $recursive);
            }

            return mkdir($path, $mode, $recursive);
        }

        return true;
    }
688638
public function makeDirectory(string $path, int $mode = 0777, bool $isRecursive = false) : bool
    {
        $result = mkdir($path, $mode, $isRecursive);
        // The directory might not get the correct mode due to umask, so we have to chmod it
        chmod($path, $mode);

        return $result;
    }
336941
public static function copy(string $path, string $newpath, bool $recursive = false)
    {
        if ($recursive) {

            if (!Filesystem::has($newpath)) {
                mkdir($newpath);
            }

            $splFileInfoArr = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST);

            foreach ($splFileInfoArr as $fullPath => $splFileinfo) {
                //skip . ..
                if (in_array($splFileinfo->getBasename(), [".", ".."])) {
                    continue;
                }

                //get relative path of source file or folder
                $_path = str_replace($path, "", $splFileinfo->getPathname());

                if ($splFileinfo->isDir()) {
                    mkdir($newpath."/".$_path);
                } else {
                    copy($fullPath, $newpath."/".$_path);
                }
            }
        } else {
            return copy($path, $newpath);
        }
    }
591000
public function mkdir($dirs, $mode = 0777)
    {
        foreach ($this->toIterator($dirs) as $dir) {
            if (is_dir($dir)) {
                continue;
            }

            if (true !== @mkdir($dir, $mode, true)) {
                throw new \RuntimeException(sprintf('Failed to create "%s".', $dir), 0, null);
            }
        }
    }
336104
protected function getRecursiveDirectoryIterator($path, $mode = RecursiveIteratorIterator::SELF_FIRST)
    {
        return new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
            $mode
        );
    }
410450
static public function rmdir($dir, $recursive = false)
    {
        $dir = realpath($dir);
        if (!is_dir($dir)) return true;
        if (true !== $recursive) return @rmdir($dir);
        $dp = @opendir($dir);
        while ($file = @readdir($dp)) {
            if ('.' === $file || '..' === $file) continue;
            $cur_file = $dir . '/' . $file;
            if (is_dir($cur_file)) {
                self::rmdir($cur_file, true);
            } elseif (is_file($cur_file)) {
                @unlink($cur_file);
            }
        }
        @closedir($dp);
        return @rmdir($dir);
    }
1327877
public static function mkdirs($dir, $mode = 0777, $recursive = true)
    {
        if (($dir === null) || $dir === '') {
            return false;
        }
        if (is_dir($dir) || $dir === '/') {
            return true;
        }
        if (self::mkdirs(dirname($dir), $mode, $recursive)) {
            return mkdir($dir, $mode);
        }
        return false;
    }