lib/scripts/raw_dump
author blanchet
Tue, 22 Mar 2011 19:04:32 +0100
changeset 42064 f4e53c8630c0
parent 38255 bf44a85c74cc
permissions -rwxr-xr-x
added first-order TPTP version of Nitpick to Isabelle, so that its sources stay in sync with Isabelle and it is easier to install new versions for SystemOnTPTP and CASC -- the tool is called "isabelle nitrox" but is deliberately omitted from the tool list unless the component is explicitly enabled, to avoid clutter

#!/usr/bin/env perl
#
# Author: Makarius
#
# raw_dump - direct copy without extra buffering
#

use warnings;
use strict;

use IO::File;


# args

my ($input, $output) = @ARGV;


# prepare files

my $infile;
my $outfile;

if ($input eq "-") { $infile = *STDIN; }
else {
  $infile = new IO::File $input, "r";
  defined $infile || die $!;
}

if ($output eq "-") { $outfile = *STDOUT; }
else {
  $outfile = new IO::File $output, "w";
  defined $outfile || die $!;
}

binmode $infile;
binmode $outfile;


# main loop

my $chunk;
while ((sysread $infile, $chunk, 65536), length $chunk > 0) {
  my $end = length $chunk;
  my $offset = 0;
  while ($offset < $end) {
    $offset += syswrite $outfile, $chunk, $end - $offset, $offset;
  }
}


# cleanup

undef $infile;
undef $outfile;