Basic cleanup options added

This commit is contained in:
2020-12-29 20:09:18 +01:00
parent cb3db37d8c
commit 863cbb6d9b
6 changed files with 123 additions and 13 deletions
+18
View File
@@ -290,4 +290,22 @@ class optimizer
return $name;
}
public static function cleanup_dir(string $dir, bool $recursion = false) : void
{
$dir = rtrim(str_replace("\\", "/", $dir), "/");
$glob = glob(utils::globsafe($dir) . "/*");
foreach ($glob as $file)
{
if (is_dir($file) && $recursion)
{
self::cleanup_dir($file, true);
@rmdir($file);
}
else
{
unlink($file);
}
}
}
}