isFile())
{
$filePath = $fileInfo->getPathname();
$modificationTimestamp = $fileInfo->getMTime();
$modificationDate = new DateTime('@' . $modificationTimestamp);
if ($modificationDate < $date_max)
{
if (unlink($filePath))
{
if ($verbose) echo "\tLe fichier [".$filePath."] a été supprimé.\n";
}
else
{
if ($verbose) echo "\t/!\\ Le fichier [".$filePath."]. est antérieur a ".$nb_jours_anteriorite." jours mais n'a pas pu être supprimé...\n";
$retour = -1;
}
}
}
}
return($retour);
// Attention : non testé !! (Pierre 09/2024) :
// Get a list of all directories inside the root directory and delete the empty ones
// $subdirectories = array_filter(glob($repertoire . '*'), 'is_dir');
// foreach ($subdirectories as $subdirectory) {
// if (count(scandir($subdirectory)) === 2) {
// // if (rmdir($subdirectory)) {
// // if ($verbose) echo "Directory: {$subdirectory} removed.
";
// // } else {
// // if ($verbose) echo "Error removing directory: {$subdirectory}.
";
// // }
// echo "Directory: {$subdirectory} removed.
";
// }
// }
}