From: Uri Guttman Date: Wed, 11 Nov 2009 05:23:58 +0000 (-0500) Subject: made binmode args for read_file and write_file be passed to binmode on X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cee624ab3b79410cdcc9e0bbd97addb51d1d09e2;p=urisagit%2FPerl-Docs.git made binmode args for read_file and write_file be passed to binmode on the opened handles. you can use this to set any binmode layer. still need to handle boolean 1 to be raw: --- diff --git a/lib/File/Slurp.pm b/lib/File/Slurp.pm index 1d043c3..73249c6 100755 --- a/lib/File/Slurp.pm +++ b/lib/File/Slurp.pm @@ -154,7 +154,6 @@ ERR # a regular file. set the sysopen mode my $mode = O_RDONLY ; - $mode |= O_BINARY if $args{'binmode'} ; #printf "RD: BINARY %x MODE %x\n", O_BINARY, $mode ; @@ -166,6 +165,10 @@ ERR goto &_error ; } + if ( my $binmode = $args{'binmode'} ) { + binmode( $read_fh, $binmode ) ; + } + # get the size of the file for use in the read loop $size_left = -s $read_fh ; @@ -336,7 +339,6 @@ sub write_file { # set the mode for the sysopen my $mode = O_WRONLY | O_CREAT ; - $mode |= O_BINARY if $args->{'binmode'} ; $mode |= O_APPEND if $args->{'append'} ; $mode |= O_EXCL if $args->{'no_clobber'} ; @@ -351,6 +353,10 @@ sub write_file { } } + if ( my $binmode = $args{'binmode'} ) { + binmode( $write_fh, $binmode ) ; + } + sysseek( $write_fh, 0, SEEK_END ) if $args->{'append'} ;