function drush_delete_dir

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

Deletes the specified file or directory and everything inside it.

Usually respects read-only files and folders. To do a forced delete use drush_delete_tmp_dir() or set the parameter $forced.


string $dir: The file or directory to delete.

bool $force: Whether or not to try everything possible to delete the directory, even if it's read-only. Defaults to FALSE.

bool $follow_symlinks: Whether or not to delete symlinked files. Defaults to FALSE--simply unlinking symbolic links.

Return value

bool FALSE on failure, TRUE if everything was deleted.

Related topics

17 calls to drush_delete_dir()
DrushMakeProject::removeGitDirectory in commands/make/
Remove the .git directory from a project.
drush_delete_dir_contents in includes/
Deletes the contents of a directory.
drush_delete_tmp_dir in includes/
Deletes the provided file or folder and everything inside it. This function explicitely tries to delete read-only files / folders.
drush_pm_download in commands/pm/
Command callback. Download Drupal core or any project.
drush_pm_updatecode_rollback in commands/pm/
Rollback the update process.

... See full list

4 string references to 'drush_delete_dir'
drush_copy_dir in includes/
Copy $src to $dest.
drush_move_dir in includes/
Move $src to $dest.
pm_update_project in commands/pm/
Update one project -- a module, theme or Drupal core.
SqlBase::query in lib/Drush/Sql/SqlBase.php
Execute a SQL query.


includes/, line 127
Filesystem utilities.


function drush_delete_dir($dir, $force = FALSE, $follow_symlinks = FALSE) {
  // Do not delete symlinked files, only unlink symbolic links
  if (is_link($dir) && !$follow_symlinks) {
    return unlink($dir);
  // Allow to delete symlinks even if the target doesn't exist.
  if (!is_link($dir) && !file_exists($dir)) {
    return TRUE;
  if (!is_dir($dir)) {
    if ($force) {
      // Force deletion of items with readonly flag.
      @chmod($dir, 0777);
    return unlink($dir);
  if (drush_delete_dir_contents($dir, $force) === FALSE) {
    return FALSE;
  if ($force) {
    // Force deletion of items with readonly flag.
    @chmod($dir, 0777);
  return rmdir($dir);