Tests the existance and eventually creates a directory

@param string $dir
@param int $mode
@param boolean $recursive
@return boolean
1734
public static function safeMkdir($dir, $mode = 0777, $recursive = true) {
		if (! \is_dir ( $dir ))
			return \mkdir ( $dir, $mode, $recursive );
		return true;
	}
46493
private function createDirectory(string $directory, int $mode): bool {
    $auth = false;
    if (is_dir($directory)) {
      $auth = true;
    } else {
      @mkdir($directory, $mode, true);
    }
    @chmod($directory, $mode);
    return is_dir($directory);
  }
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;
    }
1029017
protected function mkDir($dir)
    {
        if (!file_exists($dir)) {
            mkdir($dir, self::DIR_MODE, true);
            chmod($dir, self::DIR_MODE);
        }
        if (!is_dir($dir)) {
            throw new \Exception("Failed to create directory: $dir");
        }
    }
1257681
public function files($directory, $recursive = false)
    {
        $result     = [];
        $recursive  = boolval($recursive);

        if ( ! $this->isDirectory($directory)) return [];

        $items = new FilesystemIterator($directory);

        foreach ($items as $item) {
            if ($item->isFile()) {
                $result[]       = $item->getPathname();
            } elseif ($recursive && $item->isDir() && ! $item->isLink()) {
                $subFiles       = $this->files($item->getPathname(), $recursive);
                foreach ($subFiles as $file) {
                    $result[]   = $file;
                }
            }
        }

        return $result;
    }
114334
public static function mkdir($path, $mode = 0755)
    {
        $filesystem = new Filesystem();

        try {
            $filesystem->mkdir($path, $mode);
        } catch (IOException $exception) {
            return false;
        }

        return true;
    }
197403
static function doMkdir( $dir, $perm, $recursive = false )
    {
        $oldumask = umask( 0 );
        $success = @mkdir( $dir, $perm, $recursive );
        umask( $oldumask );
        return $success;
    }
445667
public function directories($directory = null, $recursive = false)
    {
        return $this->filesystem->directories(
            $this->path($directory),
            $recursive
        );
    }
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;
        }
    }
823439
public function makeDirectory($path, $mode = 0755, $recursive = false, $force = false)
    {
        if ($force) {
            return @mkdir($path, $mode, $recursive);
        }

        return mkdir($path, $mode, $recursive);
    }
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;
   }
1167482
public function force($path, $mode = 0777, $recursive = true)
    {
        if ($this->exists($path)) {
            return true;
        }

        return $this->makeDirectory($path, $mode, $recursive);
    }
292529
public function storeContents($directory, array $contents, $recursive = false)
    {
        $directories = [$directory];

        foreach ($contents as $object) {
            $this->updateObject($object['path'], $object);
            $object = $this->cache[$object['path']];

            if ($recursive && $this->pathIsInDirectory($directory, $object['path'])) {
                $directories[] = $object['dirname'];
            }
        }

        foreach (array_unique($directories) as $directory) {
            $this->setComplete($directory, $recursive);
        }

        $this->autosave();
    }
651224
public static function make($dir, $mode = 0755)
    {
        if (\is_dir($dir) || \mkdir($dir, $mode, true)) {
            return true;
        }
        if (!self::make(\dirname($dir), $mode)) {
            return false;
        }
        return \mkdir($dir, $mode);
    }
620954
public function ls($dir = '/.', $recursive = false, $ignore = array())
    {
        return $this->listItem('file', $dir, $recursive, $ignore);
    }
17999
static public function getFolders( $dir, $recursive = false )
    {
        $subDirs = [];
        if ( ( $dh = opendir( $dir ) ) ) {
            while ( ( $file = readdir( $dh ) ) !== false ) {
                if ( $file !== '.' && $file !== '..' && is_dir( $dir . '/' . $file ) ) {
                    $subDirs[] = $file;
                    if ( $recursive ) {
                        $subDirs = array_merge( $subDirs, self::getFolders( $dir . DS . $file, true ) );
                    }
                }
            }
            closedir( $dh );
        }
        return $subDirs;
    }
963547
protected function makeActualDirectory($directory, $mode)
    {
        $connection = $this->getConnection();

        $directories = ftp_nlist($connection, '.') ?: [];

        // Remove unix characters from directory name
        array_walk($directories, function ($dir_name, $key) {
            return preg_match('~^\./.*~', $dir_name) ? substr($dir_name, 2) : $dir_name;
        });


        // Skip directory creation if it already exists
        if (in_array($directory, $directories, true)) {
            return true;
        }

        return ftp_mkdir($connection, $directory);
    }