From 8c0e56619cb53a8396581fc07fb49fdf67b2bbb3 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Mon, 12 Mar 2007 23:15:47 +0000 Subject: * added an option to slurpFile() which causes it to not fail in case the required file doesn't exist. git-svn-id: http://svn.openslx.org/svn/openslx/trunk@762 95ad53e4-c205-0410-b2fa-d234c58c8868 --- lib/OpenSLX/Utils.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/OpenSLX/Utils.pm') diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm index 3ec46dea..cb43c6ea 100644 --- a/lib/OpenSLX/Utils.pm +++ b/lib/OpenSLX/Utils.pm @@ -68,8 +68,11 @@ sub linkFile sub slurpFile { my $file = shift; - open(F, "< $file") - or die _tr("could not open file '%s' for reading! (%s)", $file, $!); + my $mayNotExist = shift; + + if (!open(F, "< $file") && !$mayNotExist) { + die _tr("could not open file '%s' for reading! (%s)", $file, $!); + } $/ = undef; my $text = ; close(F); -- cgit v1.2.3-55-g7522