1 simpletest.module simpletest_clean_temporary_directories()

Find all leftover temporary directories and remove them.

File

core/modules/simpletest/simpletest.module, line 526
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;
      if (is_dir($path) && is_numeric($file)) {
        file_unmanaged_delete_recursive($path);
        $count++;
      }
    }
  }

  // Delete the verbose output directory if present.
  $verbose_directory = 'public://simpletest/verbose';
  if (is_dir($verbose_directory)) {
    file_unmanaged_delete_recursive($verbose_directory);
  }

  if ($count > 0) {
    backdrop_set_message(format_plural($count, 'Removed 1 temporary directory.', 'Removed @count temporary directories.'));
  }
  else {
    backdrop_set_message(t('No temporary directories to remove.'));
  }
}