Ensure the root directory exists.

@param string $root root directory path

@return void

@throws FileSystemException in case the root directory can not be created
341304
protected function ensureDirectory($root)
	{
		if (!\is_dir($root)) {
			$umask = \umask(0);
			@\mkdir($root, $this->permissionMap['dir']['public'], true);
			\umask($umask);

			if (!\is_dir($root)) {
				throw new FileSystemException('Impossible to create the root directory "' . $root . '".');
			}
		}
	}
1179312
function ensureDirExists($path, $owner = null, $mode = 0755)
    {
        if (! $this->isDir($path)) {
            $this->mkdir($path, $owner, $mode);
        }
    }
1122624
private function ensureRootDirExists(Options $options)
    {
        if (!file_exists($options->getMagentoRootDir())) {
            mkdir($options->getMagentoRootDir(), 0755, true);
        }
    }
1112963
public static function registerIncludeRoot($root=null)
  {
    if(is_null($root)){
      $root = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
    }
    if(!in_array($root, self::$frameworkRoots)){
      self::$frameworkRoots[] = $root;
      return true;
    }
    return false;
  }
1309147
private function createDirectory($directory)
    {
        if (is_dir($directory)) {
            return;
        }

        if (false === @mkdir($directory, 0777, true)) {
            throw new \RuntimeException(sprintf('Could not create directory "%s".', $dir));
        }
    }
594301
protected function createDirectory($directory)
    {
        if (!@mkdir($directory, $this->mode, true) && !is_dir($directory)) {
            throw new \RuntimeException(sprintf('The directory \'%s\' could not be created.', $directory));
        }
    }
1002752
public static function listDirsRecusrive($root)
    {
        $dirs = [];
        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) {
            if ($path->isDir()) {
                $dirs[] = $path->getPathname();
            }
        }
        return $dirs;
    }
931969
protected function _is_root( $root ) {
		$this->root = $root;

		$is_root = (bool) $this->_root_locate_template();
		if ( ! $is_root ) {
			$this->root = '';
		}

		return $is_root;
	}
584679
private function makeDirectory($path)
    {
        if ($this->isSFTP()) {
            $created = @$this->ftp->mkdir($path, true);
        } else {
            $created = @ftp_mkdir($this->ftp, $path);
        }
        if (!$created) {
            $this->fail("couldn't make directory {$path}");
        }
        $this->debug("Make directory: {$path}");
    }
483157
def ensure_dir_exists(directory):
    ""
    if directory.startswith('gs://'):
        return
    if not os.path.exists(directory):
        dbg("Making dir {}".format(directory))
    os.makedirs(directory, exist_ok=True)
1261626
protected function makeDir($directory)
	{
		if ( ! $this->files->isDirectory($this->getPath($directory)))
		{
			$this->files->makeDirectory($this->getPath($directory), 0777, true);
		}
	}
464998
protected function ensureCacheDirectoryExists($path)
    {
        if (! $this->files->exists(dirname($path))) {
            $this->files->makeDirectory(dirname($path), 0777, true, true);
        }
    }
898731
public function ensureDirectory($dirname)
    {
        if ( ! empty($dirname) && ! $this->has($dirname)) {
            $this->createDir($dirname, new Config());
        }
    }
276160
protected function ensureDirectoryIsPresent($file)
    {
        $directory = dirname($file);

        //@todo might want to check for regular file?
        if (!file_exists($directory)) {
            return $this->createDirectory($directory);
        }

        return true;
    }
900586
private static function ensureDirectoryExists(FilePathInterface $directory): void
    {
        if (!is_dir($directory->__toString())) {
            mkdir($directory->__toString(), 0700, true);
        }
    }
1204167
protected function checkDirectory(&$directory)
    {
        $directory = trim($directory, '/');

        $this->checkDirectoryExists($directory);
        $this->checkDirectoryAccess($directory);
    }
843773
private function removeEmptyDirectories($pathname, $root)
    {
        if (is_dir($pathname)
            && $pathname !== $root
            && $this->filesystem->isDirEmpty($pathname)
        ) {
            $this->filesystem->removeDirectory($pathname);

            if (!$this->removeEmptyDirectories(dirname($pathname), $root)) {
                if ($this->io->isVeryVerbose()) {
                    $this->io->writeError(sprintf('  - Removing empty directory "%s"', $pathname));
                }
            }

            return true;
        }

        return false;
    }