function Filesystem::removeDirectory
Recursively remove a directory
Uses the process component if proc_open is enabled on the PHP installation.
Return value
bool
Throws
\RuntimeException
1 call to Filesystem::removeDirectory()
- Filesystem::remove in vendor/
composer/ composer/ src/ Composer/ Util/ Filesystem.php
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ Filesystem.php, line 104
Class
- Filesystem
- @author Jordi Boggiano <j.boggiano@seld.be> @author Johannes M. Schmitt <schmittjoh@gmail.com>
Namespace
Composer\UtilCode
public function removeDirectory(string $directory) {
$edgeCaseResult = $this->removeEdgeCases($directory);
if ($edgeCaseResult !== null) {
return $edgeCaseResult;
}
if (Platform::isWindows()) {
$cmd = [
'rmdir',
'/S',
'/Q',
Platform::realpath($directory),
];
}
else {
$cmd = [
'rm',
'-rf',
$directory,
];
}
$result = $this->getProcess()
->execute($cmd, $output) === 0;
// clear stat cache because external processes aren't tracked by the php stat cache
clearstatcache();
if ($result && !is_dir($directory)) {
return true;
}
return $this->removeDirectoryPhp($directory);
}