@param string $dir      Directory
@param string $pathname Archive pathname

@return bool
@throws \RuntimeException
176902
public function archive($dir, $pathname)
    {
        try {
            $finder = (new Finder())->in($dir);
        } catch (\InvalidArgumentException $ex) {
            return false;
        }
        if (0 === $finder->count()) {
            return false;
        }
        if (true !== $this->zip->open($pathname, \ZipArchive::CREATE)) {
            throw new \RuntimeException(sprintf('Unable to create archive "%s".', $pathname));
        }
        /** @var \Symfony\Component\Finder\SplFileInfo $directory */
        foreach ($finder->directories() as $directory) {
            if (!$this->zip->addEmptyDir($directory->getRelativePathname())) {
                throw new \RuntimeException(
                    sprintf('Unable to create directory "%s" in archive "%s".', $directory->getRelativePathname(), $pathname)
                );
            }
        }
        /** @var \Symfony\Component\Finder\SplFileInfo $file */
        foreach ($finder->files() as $file) {
            if (!$this->zip->addFile($file->getPathname(), $file->getRelativePathname())) {
                throw new \RuntimeException(
                    sprintf('Unable to add file "%s" to archive "%s".', $file->getPathname(), $pathname)
                );
            }
        }
        if (!$this->zip->close()) {
            throw new \RuntimeException(sprintf('Unable to close archive "%s".', $pathname));
        }

        return true;
    }
731303
public static function recursiveDeleteDirectory(string $dirName): void {
		if (is_dir($dirName) && $dirArray = scandir($dirName)) {
			foreach ($dirArray as $k => $v) {
				if ($v !== '.' && $v !== '..') {
					if (is_dir($dirName . '/' . $v)) {
						static::recursiveDeleteDirectory($dirName . '/' . $v);
						rmdir($dirName . '/' . $v);
					}
					else
						unlink($dirName . '/' . $v);
				}
			}
		}
	}
439874
private function makeActualDirectory($dirname, $mode)
    {
        $listing = glob($this->current_working_dir . '/*', GLOB_ONLYDIR) ?: [];

        $directories = array_map(function ($value) {
            return pathinfo($value, PATHINFO_BASENAME);
        }, $listing);

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

        return @mkdir($dirname, $mode);
    }
935977
public function ensureDirectory($dirname)
    {
        $dirname = (string) $dirname;
        if ($dirname !== '' && !$this->has($dirname)) {
            $this->createDir($dirname, []);
        }
    }
968712
protected function ensureDirectory($dir)
    {
        if ($this->filesystem->isDirectory($dir)) {
            return true;
        }

        if (!@$this->filesystem->makeDirectory($dir)) {
            throw new RuntimeException("Cannot create base directory '$dir'");
        }

        return true;
    }
55872
private function buildZip($pathname)
    {
        $zip = new \ZipArchive();

        if (true !== $zip->open($pathname, \ZipArchive::CREATE)) {
            throw new ArchiveException(sprintf('Unable to create image archive "%s".', $pathname));
        }
        try {
            $finder = (new Finder())->in($this->uploadDir);
        } catch (\InvalidArgumentException $ex) {
            throw new ArchiveException(sprintf('Image upload directory "%s" does not exist.', $this->uploadDir));
        }
        /** @var \Symfony\Component\Finder\SplFileInfo $dir */
        foreach ($finder->directories() as $dir) {
            if (!$zip->addEmptyDir($dir->getRelativePathname())) {
                throw new ArchiveException(
                    sprintf('Unable to create directory "%s" in image archive "%s".', $dir->getRelativePathname(), $pathname)
                );
            }
        }
        /** @var \Symfony\Component\Finder\SplFileInfo $file */
        foreach ($finder->files() as $file) {
            if (!$zip->addFile($file->getPathname(), $file->getRelativePathname())) {
                throw new ArchiveException(
                    sprintf('Unable to add file "%s" to image archive "%s".', $file->getPathname(), $pathname)
                );
            }
        }
        if (!$zip->close()) {
            throw new ArchiveException(sprintf('Unable to close image archive "%s".', $pathname));
        }
    }
1005141
private function checkDir() : void
    {
        $dir = dirname($this->path);
        if (!is_dir($dir)) {
            if (file_exists($dir)) {
                throw new \RuntimeException($dir . ' exists and is not a directory.');
            }
            if (!@mkdir($dir, 0755, true)) {
                throw new \RuntimeException($dir . ' does not exist and could not be created.');
            }
        }
    }
1118762
public function _mkdir($dirName)
    {
        if (is_dir($dirName)) {
            return;
        }

        $success = mkdir($dirName, 0777, true);
        
        if (!$success) {
            throw new ExpectationException("Could not create $path");
        }
    }
36495
public function add_file_from_pathname($localname, $pathname) {
        if ($this->emptyziphack) {
            $this->close();
            $this->open($this->archivepathname, file_archive::OVERWRITE, $this->encoding);
        }

        if (!isset($this->za)) {
            return false;
        }

        if ($this->archivepathname === realpath($pathname)) {
            // Do not add self into archive.
            return false;
        }

        if (!is_readable($pathname) or is_dir($pathname)) {
            return false;
        }

        if (is_null($localname)) {
            $localname = clean_param($pathname, PARAM_PATH);
        }
        $localname = trim($localname, '/'); // No leading slashes in archives!
        $localname = $this->mangle_pathname($localname);

        if ($localname === '') {
            // Sorry - conversion failed badly.
            return false;
        }

        if (!$this->za->addFile($pathname, $localname)) {
            return false;
        }
        $this->modified = true;
        return true;
    }
15402
protected function createDirectory($directory)
    {
        // create parent directory if needed
        $parent = \Gaufrette\Util\Path::dirname($directory);
        if (!$this->isDir($parent)) {
            $this->createDirectory($parent);
        }

        // create the specified directory
        $created = ftp_mkdir($this->getConnection(), $directory);
        if (false === $created) {
            throw new \RuntimeException(sprintf('Could not create the \'%s\' directory.', $directory));
        }
    }
879212
protected function getTargetFile($dir, $name = null)
    {
        if (!is_dir($dir)) {
            throw new \RuntimeException("The destination folder $dir");
        }

        if (!is_writable($dir)) {
            throw new \RuntimeException("Unable to write in the $dir directory");
        }

        return new self($dir . DS . (null === $name ? $this->getBasename() : $this->getName($name)), false);
    }
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");
        }
    }
407234
public function rm($dir)
    {
        $parseDir = $this->parseLastDirectory($dir);
        if (! ssh2_sftp_rmdir($this->getSFtp(), $parseDir)) {
            throw new DirectoryException('Directory not deleted');
        }
        return true;
    }
1059167
public static function createDir($dirPath, $mode = 0711)
    {
        if (false === file_exists($dirPath)) {
            if (false === mkdir($dirPath, $mode, true)) {
                throw new RuntimeException(sprintf('unable to create directory "%s"', $dirPath));
            }
        }
    }
1157046
protected function isDir($dir)
    {
        try {
            $this->doChangeDir($dir);
            $this->doCdUp();

            return true;
        } catch (\Exception $ex) {
            return false;
        }

        return false;
    }
1093976
public function files($directoryName)
    {
        if (!$this->isDir($directoryName)) {
            throw new FileNotFoundException('Directory not found in the path [ ' . $directoryName . ' ].');
        }

        $files = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($directoryName,
                RecursiveDirectoryIterator::SKIP_DOTS
            )
        );

        return array_filter(iterator_to_array($files), 'is_file');
    }
92647
protected function _createDirectory($dir)
    {
        $old = umask(0);
        // @codingStandardsIgnoreStart
        $result = @mkdir($dir, 0755, true);
        // @codingStandardsIgnoreEnd
        umask($old);

        if ($result) {
            $this->out('Created directory ' . $dir);

            return true;
        }

        $this->err('Failed creating directory ' . $dir);

        return false;
    }