diff -r 000000000000 -r e92e765779e7 catter --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/catter Tue Jul 12 00:21:58 2011 +0200 @@ -0,0 +1,42 @@ +#! /usr/bin/perl +# Eigentlich geht das selbe mit: +# grep -v '^\[' IDX-File | while read x x file x; do test "$file" && cat DATA/$file; done +# +use 5.010; +use strict; +use warnings; +use File::Basename; +use Cwd qw(abs_path); +use autodie qw(:all); + +use constant KiB => 1024; +use constant MiB => 1024 * KiB; +use constant GiB => 1024 * MiB; + +my $BS = 64 * MiB; +my $IDX = shift // die "Need index file\n"; +my $DST = shift // die "Need destination for writing the image.\n"; +my $DATA = abs_path(dirname($IDX) . "/../data"); + +open(my $idx => $IDX); + +{ local $/ = ""; + scalar <$idx>; +} + +my $out; +if ($DST eq "-") { open($out => ">&STDOUT") } +else { open($out => ">", $DST) }; + +while (<$idx>) { + next if /^#/; + my ($blk, $hash, $path) = split; + open(my $in => "$DATA/$path"); + { + my $buffer; + local $/ = \$BS; + print {$out} $buffer while defined($buffer = <$in>); + } + close($in); +} +close($out);