function FileSystem::deleteRecursive
Same name in other branches
- 8.9.x core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::deleteRecursive()
- 10 core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::deleteRecursive()
- 11.x core/lib/Drupal/Core/File/FileSystem.php \Drupal\Core\File\FileSystem::deleteRecursive()
Overrides FileSystemInterface::deleteRecursive
File
-
core/
lib/ Drupal/ Core/ File/ FileSystem.php, line 352
Class
- FileSystem
- Provides helpers to operate on files and stream wrappers.
Namespace
Drupal\Core\FileCode
public function deleteRecursive($path, callable $callback = NULL) {
if ($callback) {
call_user_func($callback, $path);
}
if (is_dir($path)) {
$dir = dir($path);
while (($entry = $dir->read()) !== FALSE) {
if ($entry == '.' || $entry == '..') {
continue;
}
$entry_path = $path . '/' . $entry;
$this->deleteRecursive($entry_path, $callback);
}
$dir->close();
return $this->rmdir($path);
}
return $this->delete($path);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.