function emptyDirectory in Content Synchronization 8.2
Same name and namespace in other branches
- 8 src/Form/ContentImportForm.php \Drupal\content_sync\Form\emptyDirectory()
- 3.0.x src/Form/ContentImportForm.php \Drupal\content_sync\Form\emptyDirectory()
1 call to emptyDirectory()
- ContentImportForm::submitForm in src/
Form/ ContentImportForm.php - Form submission handler.
File
- src/
Form/ ContentImportForm.php, line 91
Namespace
Drupal\content_sync\FormCode
function emptyDirectory($dirname, $self_delete = false) {
if (is_dir($dirname)) {
$dir_handle = opendir($dirname);
}
if (!$dir_handle) {
return false;
}
while ($file = readdir($dir_handle)) {
if ($file != "." && $file != "..") {
if (!is_dir($dirname . "/" . $file)) {
@unlink($dirname . "/" . $file);
}
else {
emptyDirectory($dirname . '/' . $file, true);
}
}
}
closedir($dir_handle);
if ($self_delete) {
@rmdir($dirname);
}
return true;
}