Subject: | feature wanted: position in multi-part archives |
Date: | Wed, 22 Jan 2014 16:29:58 +0100 |
To: | bug-IO-Compress [...] rt.cpan.org |
From: | Marc Espie <espie [...] nerim.net> |
Use case: I'm constructing a multi-part gzip archive:
partA.gz partB.gz
I need to be able to go *back*, replace the first stream with something
else, and then copy the subsequent streams verbatims. So that I end up with
partA'.gz partB.gz
performance is really an issue. I want to recreate a new file, with a tweaked
partA, then and untweaked partB.
I can do that by looking at IO::Uncompress::Gunzip internals.
e.g.,
pseudo code would look like:
my $fh = IO::Uncompress::Gunzip->new('file.gz');
#(<read first stream>)
my $out = IO::Compress::Gzip->new('out.gz');
#(<write modified first stream>)
# XXX note location
$length = *$fh->{CompSize}->get64bit + *$fh->{Info}{HeaderLength} +
*$fh->{Info}{TrailerLength};
$fh->close;
$out->close;
# copy verbatim file:
open($fh, '<', 'file.gz');
$fh->seek($length, 0);
open($out, '>>', 'out.gz');
File::Copy::copy($fh, $out);
close($fh);
close($out);
I'd like to have something clean to do that. At the end of a stream,
I want to know which position I need to seek to in the *compressed file*
to be able to copy the next stream, e.g., the XXX line.