function unish_file_delete_recursive

8.0.x bootstrap.inc unish_file_delete_recursive($dir, $force = FALSE, $follow_symlinks = FALSE)
6.x drush_testcase.inc unish_file_delete_recursive($dir, $force = FALSE, $follow_symlinks = FALSE)
7.x bootstrap.inc unish_file_delete_recursive($dir, $force = FALSE, $follow_symlinks = FALSE)
4.x drush_testcase.inc unish_file_delete_recursive($dir)
5.x drush_testcase.inc unish_file_delete_recursive($dir)
master bootstrap.inc unish_file_delete_recursive($dir, $force = TRUE, $follow_symlinks = FALSE)

Same code as drush_delete_dir().

Parameters

string $dir:

Return value

boolean

See also

drush_delete_dir()

5 calls to unish_file_delete_recursive()
archiveDumpCase::testArchiveRestoreNoCore in tests/archiveDumpTest.php
Test archive-restore for a site archive (--no-core).
archiveDumpCase::unTar in tests/archiveDumpTest.php
Untar an archive and return the path to the untarred folder.
Drush_TestCase::setUpFreshSandBox in tests/drush_testcase.inc
Remove any pre-existing sandbox, then create a new one.
Drush_TestCase::tearDownAfterClass in tests/drush_testcase.inc
Runs after all tests in a class are run. Remove sandbox directory.
pmDownloadCase::testDestination in tests/pmDownloadTest.php

File

tests/drush_testcase.inc, line 533

Code

function unish_file_delete_recursive($dir) {
  if (!file_exists($dir)) {
    return TRUE;
  }
  @chmod($dir, 0777); // Make file/dir writeable
  if (!is_dir($dir)) {
    return unlink($dir);
  }
  foreach (scandir($dir) as $item) {
    if ($item == '.' || $item == '..') {
      continue;
    }
    if (!unish_file_delete_recursive($dir . '/' . $item)) {
      return FALSE;
    }
  }
  return rmdir($dir);
}