Commit 7f42a180 authored by Franco Fichtner's avatar Franco Fichtner

inc: geez, properly delete directories as well #124

That's what you get for using "@" muting informative errors.
parent 6fa394bb
...@@ -1025,14 +1025,18 @@ function mwexec_bg($command, $mute = false, $clearsigmask = false) ...@@ -1025,14 +1025,18 @@ function mwexec_bg($command, $mute = false, $clearsigmask = false)
mwexec("/usr/sbin/daemon -f {$command}", $mute, $clearsigmask); mwexec("/usr/sbin/daemon -f {$command}", $mute, $clearsigmask);
} }
/* unlink a file, if it exists */ /* unlink a file or directory, if it exists */
function unlink_if_exists($fn) { function unlink_if_exists($fn)
{
$to_do = glob($fn); $to_do = glob($fn);
if(is_array($to_do)) {
foreach($to_do as $filename) foreach($to_do as $filename) {
@unlink($filename); if (is_dir($filename)) {
/* rmdir() is not recursive... */
mwexecf('/bin/rm -r %s', $filename);
} else { } else {
@unlink($fn); unlink($filename);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment