From 7897c609d415e2362b8c42c3b918a7ebcb5c4bda Mon Sep 17 00:00:00 2001 From: pcanterino <> Date: Wed, 9 Feb 2005 18:21:58 +0000 Subject: [PATCH 1/1] file_read() is now able to open a file in binary mode (maybe we will need it) --- modules/File/Access.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/File/Access.pm b/modules/File/Access.pm index 4fa468d..d892ed8 100644 --- a/modules/File/Access.pm +++ b/modules/File/Access.pm @@ -7,7 +7,7 @@ package File::Access; # using only one command # # Author: Patrick Canterino -# Last modified: 2005-01-06 +# Last modified: 2005-02-09 # use strict; @@ -134,17 +134,20 @@ sub file_lock(*$) # # Read out a file completely # -# Params: File +# Params: 1. File +# 2. true => open in binary mode +# false => open in normal mode (default) # # Return: Contents of the file (Scalar Reference) -sub file_read($) +sub file_read($;$) { - my $file = shift; + my ($file,$binary) = @_; local *FILE; sysopen(FILE,$file,O_RDONLY) or return; file_lock(FILE,LOCK_SH) or do { close(FILE); return }; + binmode(FILE) if($binary); read(FILE, my $content, -s $file); -- 2.34.1