function drush_delete_dir

8.0.x filesystem.inc drush_delete_dir($dir, $force = FALSE, $follow_symlinks = FALSE)
6.x filesystem.inc drush_delete_dir($dir, $force = FALSE, $follow_symlinks = FALSE)
7.x filesystem.inc drush_delete_dir($dir, $force = FALSE, $follow_symlinks = FALSE)
3.x drush.inc drush_delete_dir($dir)
4.x drush.inc drush_delete_dir($dir)
5.x filesystem.inc drush_delete_dir($dir, $force = FALSE, $follow_symlinks = FALSE)
master filesystem.inc drush_delete_dir($dir, $force = FALSE, $follow_symlinks = FALSE)

Deletes the provided file or folder and everything inside it.

Parameters

$dir: The directory to delete

Return value

FALSE on failure, TRUE if everything was deleted

Related topics

5 calls to drush_delete_dir()
drush_pm_updatecode_rollback in commands/pm/updatecode.pm.inc
drush_upgrade_site_upgrade in commands/core/upgrade.drush.inc
Main command hook for site-upgrade.
_drush_delete_registered_files in includes/drush.inc
Delete all of the registered temporary files.
_pm_update_core in commands/pm/updatecode.pm.inc
Update drupal core, following interactive confirmation from the user.
_pm_update_move_files in commands/pm/updatecode.pm.inc
Move some files from one location to another
3 string references to 'drush_delete_dir'
drush_copy_dir in includes/drush.inc
Copy $src to $dest.
drush_move_dir in includes/drush.inc
Move $src to $dest.
pm_update_project in commands/pm/updatecode.pm.inc
Update one project -- a module, theme or Drupal core.

File

includes/drush.inc, line 1625
The drush API implementation and helpers.

Code

function drush_delete_dir($dir) {
  if (!file_exists($dir)) {
    return TRUE;
  }
  if (!is_dir($dir)) {
    return unlink($dir);
  }
  foreach (scandir($dir) as $item) {
    if ($item == '.' || $item == '..') {
      continue;
    }
    if (!drush_delete_dir($dir . '/' . $item)) {
      return FALSE;
    }
  }
  return rmdir($dir);
}