function drush_delete_dir
| 6.x filesystem.inc | drush_delete_dir($dir, $force = FALSE, $follow_symlinks = FALSE) |
| 5.x filesystem.inc | drush_delete_dir($dir, |
| 3.x drush.inc | drush_delete_dir($dir) |
| 4.x drush.inc | drush_delete_dir($dir) |
Deletes the provided file or folder 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
$dir: The file or directory to delete.
$force: Try whatever possible to delete the directory - also read-only ones.
$follow_symlinks: Do not delete symlinked files. Simply unlink symbolic links.
Return value
FALSE on failure, TRUE if everything was deleted.
Related topics
14 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_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.
- drush_pm_download in commands/
pm/ download.pm.inc - Command callback. Download Drupal core or any project.
- drush_pm_updatecode_rollback in commands/
pm/ updatecode.pm.inc
3 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.
- pm_update_project in commands/
pm/ updatecode.pm.inc - Update one project -- a module, theme or Drupal core.
File
- includes/
filesystem.inc, line 118
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, 0777);
}
return unlink($dir);
}
foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..') {
continue;
}
if ($force) {
@chmod($dir, 0777);
}
if (!drush_delete_dir($dir . '/' . $item, $force)) {
return FALSE;
}
}
if ($force) {
// Force deletion of items with readonly flag.
@chmod($dir, 0777);
}
return rmdir($dir);
}