Don't delete parent directories

This commit is contained in:
Jay Trees 2022-01-21 14:53:19 +01:00
parent f6f2b59311
commit d2120b9b61

View file

@ -9,6 +9,10 @@
function delete_directory(string $directoryToDelete) function delete_directory(string $directoryToDelete)
{ {
foreach (scandir($directoryToDelete) as $filename) { foreach (scandir($directoryToDelete) as $filename) {
if (in_array($filename, array('.', '..'))) {
continue;
}
$filepath = $directoryToDelete . '/' . $filename; $filepath = $directoryToDelete . '/' . $filename;
if (is_file($filepath)) { if (is_file($filepath)) {