function simpletest_clean_temporary_directories in SimpleTest 7
Same name and namespace in other branches
- 8.3 simpletest.module \simpletest_clean_temporary_directories()
- 6.2 simpletest.module \simpletest_clean_temporary_directories()
- 6 simpletest.module \simpletest_clean_temporary_directories()
- 7.2 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 ./
simpletest.module - Remove all temporary database tables and directories.
File
- ./
simpletest.module, line 441 - Provides testing functionality.
Code
function simpletest_clean_temporary_directories() {
$files = scandir('public://');
$count = 0;
foreach ($files as $file) {
$path = 'public://' . $file;
if (is_dir($path) && preg_match('/^simpletest\\d+/', $file)) {
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.'));
}
}