function cpn_recursive_delete in Code per Node 6
Recursive delete function.
1 call to cpn_recursive_delete()
- cpn_uninstall in ./
cpn.install - Implementation of hook_uninstall().
File
- ./
cpn.install, line 103 - Installation, schema and update hook implementations.
Code
function cpn_recursive_delete($path) {
if (is_file($path) or is_link($path)) {
unlink($path);
}
elseif (is_dir($path)) {
$d = dir($path);
while (($entry = $d
->read()) !== FALSE) {
if ($entry == '.' or $entry == '..') {
continue;
}
$entry_path = $path . '/' . $entry;
cpn_recursive_delete($entry_path);
}
$d
->close();
rmdir($path);
}
else {
watchdog('cpn', 'Unknown file type(%path) stat: %stat ', array(
'%path' => $path,
'%stat' => print_r(stat($path), 1),
), WATCHDOG_ERROR);
}
}