6 die "usage: $0 [pieces] [filename]\n" if (@ARGV != 2);
11 die "$file does not exist\n" if (-e
$file == 0);
13 my $copyLoopSize = 16 * 1024;
14 my $copyLoops = ((-s
$file) / $copyLoopSize) / $pieces;
16 # write out all the interim files, excluding the last (since it's the entire file)
17 foreach my $piece (1 .. $pieces-1)
22 my $dir = "piece" . $piece;
24 open(OUT
, ">" . $dir . "/" . $file);
27 foreach (1 .. ($piece * $copyLoops))
30 read IN
, $buffer, $copyLoopSize;
43 my $dir = "piece" . $pieces;
45 open(OUT
, ">" . $dir . "/" . $file);
51 read IN
, $buffer, $copyLoopSize;
52 last if (length $buffer == 0);
60 system("md5sum -b $file piece*/*");