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 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.

Parameters

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()
DrushFileCache::clear in includes/cache.inc
Expire data from the cache. If called without arguments, expirable entries will be cleared from all known cache bins.
DrushMakeProject::removeGitDirectory in commands/make/make.project.inc
Remove the .git directory from a project.
drush_core_pre_site_install in commands/core/site_install.drush.inc
Perform setup tasks for installation.
drush_delete_dir_contents in includes/filesystem.inc
Deletes the contents of a directory.
drush_delete_tmp_dir in includes/filesystem.inc
Deletes the provided file or folder and everything inside it. This function explicitely tries to delete read-only files / folders.

... See full list

4 string references to 'drush_delete_dir'
drush_copy_dir in includes/filesystem.inc
Copy $src to $dest.
drush_move_dir in includes/filesystem.inc
Move $src to $dest.
drush_sql_query in commands/sql/sql.drush.inc
Command callback. Executes the given SQL query on the Drupal database.
pm_update_project in commands/pm/updatecode.pm.inc
Update one project -- a module, theme or Drupal core.

File

includes/filesystem.inc, line 126
Filesystem utilities.

Code

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, );
    }
    return unlink($dir);
  }
  if (drush_delete_dir_contents($dir, $force) === FALSE) {
    return FALSE;
  }
  if ($force) {
    // Force deletion of items with readonly flag.
    @chmod($dir, );
  }
  return rmdir($dir);
}