lib/scripts/raw_dump
changeset 45158 db4bf4fb5492
parent 45157 efc2e2d80218
child 45161 699848baf70b
     1.1 --- a/lib/scripts/raw_dump	Sun Oct 16 21:49:47 2011 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,56 +0,0 @@
     1.4 -#!/usr/bin/env perl
     1.5 -#
     1.6 -# Author: Makarius
     1.7 -#
     1.8 -# raw_dump - direct copy without extra buffering
     1.9 -#
    1.10 -
    1.11 -use warnings;
    1.12 -use strict;
    1.13 -
    1.14 -use IO::File;
    1.15 -
    1.16 -
    1.17 -# args
    1.18 -
    1.19 -my ($input, $output) = @ARGV;
    1.20 -
    1.21 -
    1.22 -# prepare files
    1.23 -
    1.24 -my $infile;
    1.25 -my $outfile;
    1.26 -
    1.27 -if ($input eq "-") { $infile = *STDIN; }
    1.28 -else {
    1.29 -  $infile = new IO::File $input, "r";
    1.30 -  defined $infile || die $!;
    1.31 -}
    1.32 -
    1.33 -if ($output eq "-") { $outfile = *STDOUT; }
    1.34 -else {
    1.35 -  $outfile = new IO::File $output, "w";
    1.36 -  defined $outfile || die $!;
    1.37 -}
    1.38 -
    1.39 -binmode $infile;
    1.40 -binmode $outfile;
    1.41 -
    1.42 -
    1.43 -# main loop
    1.44 -
    1.45 -my $chunk;
    1.46 -while ((sysread $infile, $chunk, 65536), length $chunk > 0) {
    1.47 -  my $end = length $chunk;
    1.48 -  my $offset = 0;
    1.49 -  while ($offset < $end) {
    1.50 -    $offset += syswrite $outfile, $chunk, $end - $offset, $offset;
    1.51 -  }
    1.52 -}
    1.53 -
    1.54 -
    1.55 -# cleanup
    1.56 -
    1.57 -undef $infile;
    1.58 -undef $outfile;
    1.59 -