equal
deleted
inserted
replaced
|
1 #! /usr/bin/perl |
|
2 # Eigentlich geht das selbe mit: |
|
3 # grep -v '^\[' IDX-File | while read x x file x; do test "$file" && cat DATA/$file; done |
|
4 # |
|
5 use 5.010; |
|
6 use strict; |
|
7 use warnings; |
|
8 use File::Basename; |
|
9 use Cwd qw(abs_path); |
|
10 use autodie qw(:all); |
|
11 |
|
12 use constant KiB => 1024; |
|
13 use constant MiB => 1024 * KiB; |
|
14 use constant GiB => 1024 * MiB; |
|
15 |
|
16 my $BS = 64 * MiB; |
|
17 my $IDX = shift // die "Need index file\n"; |
|
18 my $DST = shift // die "Need destination for writing the image.\n"; |
|
19 my $DATA = abs_path(dirname($IDX) . "/../data"); |
|
20 |
|
21 open(my $idx => $IDX); |
|
22 |
|
23 { local $/ = ""; |
|
24 scalar <$idx>; |
|
25 } |
|
26 |
|
27 my $out; |
|
28 if ($DST eq "-") { open($out => ">&STDOUT") } |
|
29 else { open($out => ">", $DST) }; |
|
30 |
|
31 while (<$idx>) { |
|
32 next if /^#/; |
|
33 my ($blk, $hash, $path) = split; |
|
34 open(my $in => "$DATA/$path"); |
|
35 { |
|
36 my $buffer; |
|
37 local $/ = \$BS; |
|
38 print {$out} $buffer while defined($buffer = <$in>); |
|
39 } |
|
40 close($in); |
|
41 } |
|
42 close($out); |