| Versionen | |
|---|---|
| drupal7 | file_unmanaged_delete_recursive($path) |
Recursively delete all files and directories in the specified filepath.
If the specified path is a directory then the function will call itself recursively to process the contents. Once the contents have been removed the directory will also be removed.
If the specified path is a file then it will be passed to file_unmanaged_delete().
Note that this only deletes visible files with write permission.
see file_unmanaged_delete()
$path A string containing a file or directory path.
TRUE for success or path does not exist, or FALSE in the event of an error.
includes/
<?php
function file_unmanaged_delete_recursive($path) {
if (is_dir($path)) {
$dir = dir($path);
while (($entry = $dir->read()) !== FALSE) {
if ($entry == '.' || $entry == '..') {
continue;
}
$entry_path = $path . '/' . $entry;
file_unmanaged_delete_recursive($entry_path);
}
$dir->close();
return rmdir($path);
}
return file_unmanaged_delete($path);
}
?>
Kommentare
Kommentar hinzufügen