You are here

function simpletest_file_unmanaged_delete_recursive in SimpleTest 6.2

Recursively delete all files and directories in the specified filepath.

If the specified path is a directory then the function will call itself recursively to process the contents. Once the contents have been removed the directory will also be removed.

If the specified path is a file then it will be passed to file_unmanaged_delete().

Note that this only deletes visible files with write permission.

Parameters

$path: A string containing either an URI or a file or directory path.

Return value

TRUE for success or if path does not exist, FALSE in the event of an error.

See also

file_unmanaged_delete()

4 calls to simpletest_file_unmanaged_delete_recursive()
DrupalWebTestCase::tearDown in ./drupal_web_test_case.php
Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix.
simpletest_clean_temporary_directories in ./simpletest.module
Find all leftover temporary directories and remove them.
simpletest_run_tests in ./simpletest.module
Actually runs tests.
simpletest_uninstall in ./simpletest.install
Implements hook_uninstall().

File

./simpletest.module, line 565
Provides testing functionality.

Code

function simpletest_file_unmanaged_delete_recursive($path) {
  if (is_dir($path)) {
    $dir = dir($path);
    while (($entry = $dir
      ->read()) !== FALSE) {
      if ($entry == '.' || $entry == '..') {
        continue;
      }
      $entry_path = $path . '/' . $entry;
      simpletest_file_unmanaged_delete_recursive($entry_path);
    }
    $dir
      ->close();
    return rmdir($path);
  }
  elseif (is_file($path)) {
    return unlink($path);
  }
}