function Filesystem::emptyDirectory
Return value
void
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ Filesystem.php, line 72
Class
- Filesystem
- @author Jordi Boggiano <j.boggiano@seld.be> @author Johannes M. Schmitt <schmittjoh@gmail.com>
Namespace
Composer\UtilCode
public function emptyDirectory(string $dir, bool $ensureDirectoryExists = true) {
if (is_link($dir) && file_exists($dir)) {
$this->unlink($dir);
}
if ($ensureDirectoryExists) {
$this->ensureDirectoryExists($dir);
}
if (is_dir($dir)) {
$finder = Finder::create()->ignoreVCS(false)
->ignoreDotFiles(false)
->depth(0)
->in($dir);
foreach ($finder as $path) {
$this->remove((string) $path);
}
}
}