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