Recursive remove folder

This commit is contained in:
Jeroen De Meerleer 2021-08-05 18:15:56 +02:00
parent b65ae0ab71
commit 5af9af91e1
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -50,16 +50,15 @@ class RefreshCommand extends Command
return Command::FAILURE;
}
function recursiveRemoveDirectory($directory)
function recursiveRemoveDirectory($dir)
{
foreach(glob($directory . "/*") as $file)
{
if(is_dir($file)) {
$this->recursiveRemoveDirectory($file);
} else {
unlink($file);
}
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? $this->recursiveRemoveDirectory("$dir/$file") : unlink("$dir/$file");
}
rmdir($directory);
return rmdir($dir);
}
}