# HG changeset patch # User Heiko Schlittermann (JUMPER) # Date 1313760600 -7200 # Node ID 603b47708d374223d8fe7da2fdfd0e379aac2161 # Parent e65d90b1682d6d9f22d3c1f4396c1f899dd5d7c5 using sysread when possible diff -r e65d90b1682d -r 603b47708d37 bin/imager.save --- a/bin/imager.save Fri Aug 19 15:10:12 2011 +0200 +++ b/bin/imager.save Fri Aug 19 15:30:00 2011 +0200 @@ -121,7 +121,6 @@ open(my $in => $src); binmode($in); - local $/ = \$o{blocksize}; local $| = 1; my %stats = ( @@ -145,14 +144,15 @@ }; $SIG{ALRM}->(); - while (my $buffer = <$in>) { + for (my $blknr = 0; sysread($in => my $buffer, $o{blocksize}) > 0; ++$blknr) { + my ($file, $ext, $cs); $file = $cs = md5_hex($buffer); $file =~ s/(?(?...).*)/$+{prefix}\/$+{fn}/g; $ext .= $o{pass} ? ".x" : ""; # the extension we do not put into the index - push @{ $index{BLOCKS} }, sprintf "%12d %s %s" => ($. - 1), + push @{ $index{BLOCKS} }, sprintf "%12d %s %s" => $blknr, $cs, $file; if (not Imager::get_file("$data/$file")) { @@ -184,7 +184,7 @@ syswrite $out => $buffer; close($out); rename($out => "$data/$file$ext"); - $index{BLOCKS}[$. - 1] .= " *"; + $index{BLOCKS}[$blknr] .= " *"; $stats{written}++; } else { diff -r e65d90b1682d -r 603b47708d37 lib/Imager.pm --- a/lib/Imager.pm Fri Aug 19 15:10:12 2011 +0200 +++ b/lib/Imager.pm Fri Aug 19 15:30:00 2011 +0200 @@ -24,16 +24,14 @@ given ($file) { when (/\.gz\.x$/) { open(my $fh => "openssl @{[CIPHER]} -d -pass $::o{pass} -in $file|"); - local $/ = undef; gunzip($fh => $buffer) or die $GunzipError; } when (/\.gz$/) { gunzip($file => $buffer) or die $GunzipError } when (/\.x$/) { open(my $fh => "openssl @{[CIPHER]} -d -pass $::o{pass} -in $file|"); - local $/ = undef; $$buffer = <$fh>; } - default { open(my $fh => $file); local $/ = undef; $$buffer = <$fh> } + default { open(my $fh => $file); sysread $fh => $$buffer, -s $fh } } }