Skip to content

Commit

Permalink
add rmdir after delete file
Browse files Browse the repository at this point in the history
  • Loading branch information
Hotfirenet committed Dec 18, 2024
1 parent c0b1d86 commit 06dd91b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions plugin_info/configurationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,29 @@ function processDirectories($directories, $newId) {
echo "Votre plugin possede t-il un démon ? (oui/non) : ";
$demonResponse = trim(fgets(STDIN));

echo "Vous avez entré '$demonResponse'. Confirmez-vous cette modification ? (oui/non) : ";
$confirmationDemon = trim(fgets(STDIN));

if (strtolower($confirmationDemon) === 'oui' || strtolower($confirmationDemon) === 'o') {

$dataJson['hasOwnDeamon'] = true;
echo "La prise en compte du démon est activée.\n";
} else {
echo "Suppression du repertoire démon.\n";
$demonDirectory = __DIR__ . '/../resources';
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($demonDirectory));
foreach ($files as $file) {
if ($file->isFile()) {
unlink($file->getRealPath());
echo "Vous avez entré '$demonResponse'. Confirmez-vous cette modification ? (oui/non) : ";
$confirmationDemon = trim(fgets(STDIN));

if (strtolower($confirmationDemon) === 'oui' || strtolower($confirmationDemon) === 'o') {
echo "Suppression du repertoire démon.\n";
$demonDirectory = __DIR__ . '/../resources';
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($demonDirectory, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($files as $file) {
if ($file->isFile()) {
unlink($file->getRealPath());
} elseif ($file->isDir()) {
rmdir($file->getRealPath());
}
}
rmdir($demonDirectory);
}
}

Expand Down

0 comments on commit 06dd91b

Please sign in to comment.