Skip to content

Commit

Permalink
ADD deleteDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
tomitomas committed Sep 4, 2024
1 parent 03c198a commit d07ff69
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/tomitomasEqLogicTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,29 @@ public static function backupExclude() {
];
}

public static function deleteDirectory($dir) {
if (!file_exists($dir)) {
return false;
}

if (!is_dir($dir)) {
return false;
}

$items = array_diff(scandir($dir), array('.', '..'));

foreach ($items as $item) {
$path = $dir . DIRECTORY_SEPARATOR . $item;

if (is_dir($path)) {
self::deleteDirectory($path);
} else {
unlink($path);
}
}

return rmdir($dir);
}

/*******************************
* From @Mips2648
Expand Down

0 comments on commit d07ff69

Please sign in to comment.