public function DirectoryOperations::directoryRemove in AT Tools 8
Same name and namespace in other branches
- 8.3 at_theme_generator/src/File/DirectoryOperations.php \Drupal\at_theme_generator\File\DirectoryOperations::directoryRemove()
- 8.2 at_theme_generator/src/File/DirectoryOperations.php \Drupal\at_theme_generator\File\DirectoryOperations::directoryRemove()
Delete a folder and all files recursively.
Parameters
$directory:
Return value
bool Returns TRUE on success, FALSE on failure Returns TRUE on success, FALSE on failure
File
- at_theme_generator/
src/ File/ DirectoryOperations.php, line 62 - Contains \Drupal\at_theme_generator\File\DirectoryOperations
Class
Namespace
Drupal\at_theme_generator\FileCode
public function directoryRemove($directory) {
if (!file_exists($directory)) {
return false;
}
if (is_file($directory)) {
return unlink($directory);
}
$dir = dir($directory);
while (false !== ($entry = $dir
->read())) {
if ($entry == '.' || $entry == '..') {
continue;
}
self::directoryRemove("{$directory}/{$entry}");
}
$dir
->close();
return rmdir($directory);
}