function simpletest_clean_temporary_directories in Drupal 7
Same name and namespace in other branches
- 8 core/modules/simpletest/simpletest.module \simpletest_clean_temporary_directories()
Find all leftover temporary directories and remove them.
1 call to simpletest_clean_temporary_directories()
- simpletest_clean_environment in modules/
simpletest/ simpletest.module - Remove all temporary database tables and directories.
File
- modules/
simpletest/ simpletest.module, line 589 - Provides testing functionality.
Code
function simpletest_clean_temporary_directories() {
$count = 0;
if (is_dir('public://simpletest')) {
$files = scandir('public://simpletest');
foreach ($files as $file) {
$path = 'public://simpletest/' . $file;
// Ensure that cache directories are cleaned as well.
if (is_dir($path) && (is_numeric($file) || strpos($file, '1c') === 0)) {
file_unmanaged_delete_recursive($path);
$count++;
}
}
}
if ($count > 0) {
drupal_set_message(format_plural($count, 'Removed 1 temporary directory.', 'Removed @count temporary directories.'));
}
else {
drupal_set_message(t('No temporary directories to remove.'));
}
}