function _imagecache_recursive_delete in ImageCache 5.2
Same name and namespace in other branches
- 5 imagecache.module \_imagecache_recursive_delete()
- 6.2 imagecache.module \_imagecache_recursive_delete()
Recursively delete all files and folders in the specified filepath, then delete the containing folder.
Note that this only deletes visible files with write permission.
Parameters
string $path: A filepath relative to file_directory_path.
1 call to _imagecache_recursive_delete()
- imagecache_preset_flush in ./
imagecache.module - Flush cached media for a preset.
File
- ./
imagecache.module, line 671 - Dynamic image resizer and image cacher.
Code
function _imagecache_recursive_delete($path) {
if (is_file($path) || is_link($path)) {
unlink($path);
}
elseif (is_dir($path)) {
$d = dir($path);
while (($entry = $d
->read()) !== false) {
if ($entry == '.' || $entry == '..') {
continue;
}
$entry_path = $path . '/' . $entry;
_imagecache_recursive_delete($entry_path);
}
$d
->close();
rmdir($path);
}
else {
watchdog('imagecache', t('Unknown file type(%path) stat: %stat ', array(
'%path' => $path,
'%stat' => print_r(stat($path), 1),
)), WATCHDOG_ERROR);
}
}