function Drush_TestCase::file_delete_recursive

4.x drush_testcase.inc Drush_TestCase::file_delete_recursive($dir)

Same code as drush_delete_dir().

Parameters

string $dir:

Return value

boolean

See also

drush_delete_dir()

File

tests/drush_testcase.inc, line 268

Class

Drush_TestCase

Code

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