From d5e736038704bf5dad49f06541658930d6fc3deb Mon Sep 17 00:00:00 2001 From: pcanterino <> Date: Fri, 26 Sep 2003 17:29:13 +0000 Subject: [PATCH] Some checks for the return values of open(), close() and print() added --- modules/File/Access.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/File/Access.pm b/modules/File/Access.pm index 81b6851..da783d3 100644 --- a/modules/File/Access.pm +++ b/modules/File/Access.pm @@ -7,7 +7,7 @@ package File::Access; # with only one command # # Author: Patrick Canterino -# Last modified: 09-20-2003 +# Last modified: 09-26-2003 # use strict; @@ -107,9 +107,9 @@ sub file_read($) my $file = shift; local *FILE; - open(FILE,"<",$file); + open(FILE,"<",$file) or return; read(FILE, my $content, -s $file); - close(FILE); + close(FILE) or return; return \$content; } @@ -121,7 +121,7 @@ sub file_read($) # Params: 1. File # 2. File content as Scalar Reference # -# Return: Status Code (Boolean) +# Return: Status code (Boolean) sub file_save($$) { @@ -130,10 +130,10 @@ sub file_save($$) local *FILE; open(FILE,">",$temp) or return; - print FILE $$content; - close(FILE) or return; + print FILE $$content or do { close(FILE); return }; + close(FILE) or return; - rename($temp,$file) or return; + rename($temp,$file) or return; return 1; } -- 2.34.1