diff options
| author | 2014-12-21 17:53:03 +0100 | |
|---|---|---|
| committer | 2014-12-21 17:53:03 +0100 | |
| commit | 5f327abeeca1953ff9d11f93afb9fbd9ceb825ba (patch) | |
| tree | 487886ca143670aeb7f418ad954e82fe3fbb7b8c /lib/lib_rss.php | |
| parent | c804a30140ecad805f5e1e757ce27612ff7f7022 (diff) | |
Add recursive_unlink function in dev branch
Diffstat (limited to 'lib/lib_rss.php')
| -rw-r--r-- | lib/lib_rss.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 264c69d58..2400ba708 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -319,3 +319,27 @@ function check_install_database() { return $status; } + +/** + * Remove a directory recursively. + * + * From http://php.net/rmdir#110489 + * + * @param $dir the directory to remove + */ +function recursive_unlink($dir) { + if (!is_dir($dir)) { + return true; + } + $files = array_diff(scandir($dir), array('.', '..')); + foreach ($files as $filename) { + $filename = $dir . '/' . $filename; + if (is_dir($filename)) { + @chmod($filename, 0777); + recursive_unlink($filename); + } else { + unlink($filename); + } + } + return rmdir($dir); +} |
