summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-12-07 13:34:08 -0200
committerRenato Botelho <renato@netgate.com>2015-12-07 13:34:08 -0200
commit3ff153307024a5531dfac5c576a3f6dc860cffe1 (patch)
treef00444958cfaea0d9c49f279903697844ee0abb5 /src
parent45dceed15bb1e96c278ced739542bb1e98257ad6 (diff)
parenta85ad858e4b98ba8b818e35a0c51e8d36413b17c (diff)
downloadpfsense-3ff153307024a5531dfac5c576a3f6dc860cffe1.zip
pfsense-3ff153307024a5531dfac5c576a3f6dc860cffe1.tar.gz
Merge pull request #2153 from stilez/patch-3
Diffstat (limited to 'src')
-rw-r--r--src/etc/inc/util.inc10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc
index 88d48fa..8bf41da 100644
--- a/src/etc/inc/util.inc
+++ b/src/etc/inc/util.inc
@@ -1494,13 +1494,13 @@ function mwexec_bg($command, $clearsigmask = false) {
return mwexec($command, false, $clearsigmask, true);
}
-/* unlink a file, if it exists */
+/* unlink a file, or pattern-match of a file, if it exists
+ if the file/path contains glob() compatible wildcards, all matching files will be unlinked
+ if no matches, no error occurs */
function unlink_if_exists($fn) {
$to_do = glob($fn);
- if (is_array($to_do)) {
- foreach ($to_do as $filename) {
- @unlink($filename);
- }
+ if (is_array($to_do) && count($to_do) > 0) {
+ array_map("unlink", $to_do);
} else {
@unlink($fn);
}
OpenPOWER on IntegriCloud