You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although I have read the documentation of IO::Compress::Gzip, it is unclear to me how the following functional call
gzip($inputFile => $outputFilehandle, {Strict => 0}) or die "gzip failed: $GzipError\n";
could be translated into an OO approach. $inputFile is a filename. $outputFilehandle is a raw read+write filehandle.
Furthermore I would like to know which instance(object) method I could use to access the header information of the zip archive. I have seen IO::Uncompress::Gunzip::getHeaderInfo() but I cannot believe that no such method exists for a gzip object itself because such an object should known how it has created the zip archive including its header.
Although I have read the documentation of IO::Compress::Gzip, it is unclear to me how the following functional call
gzip($inputFile => $outputFilehandle, {Strict => 0}) or die "gzip failed: $GzipError\n";
could be translated into an OO approach. $inputFile is a filename. $outputFilehandle is a raw read+write filehandle.
here is the equivalent OO
use IO::Compress::Gzip qw($GzipError) ;
my $inputFile = "/tmp/x";
my $gz = new IO::Compress::Gzip $outputFilehandle, Strict =>0
or die "Cannot create gzip object: $GzipError\n";
open my $fh, '<', $inputFile
or die "Cannot open $inputFile: $!\n" ;
while (read($fh, my $buffer, 1024 * 16))
{
$gz->write($buffer);
}
$gz->close();
Furthermore I would like to know which instance(object) method I could use to access the header information of the zip archive. I have seen IO::Uncompress::Gunzip::getHeaderInfo() but I cannot believe that no such method exists for a gzip object itself because such an object should known how it has created the zip archive including its header.
There is no public interface to access the gzip header in IO::Compress::Gzip because I've never seen the need. Can you explain the use-case you want it for?
or the question: What is the equivalent of gzip --list as a use-case? But our use-case that has brought us to the above stackoverflow article was this:
We have used the functional interface of IO::Compress::Gzip to zip an input file. Due to a race condition (a bug at our end:-() there was a discrepancy between the content of the original input file and the zip file. The zip file was not(!) corrupt but after unzipping the zip file it was different from original input file due to the race condition. We thought it would be a good idea to log the compressed and the uncompressed file size (ISIZE) from the perspective of IO::Compress::Gzip. We don't wanted to make extra stat() calls before and/or after the crompress action. We wanted the compress action(object) to provide a feedback.
Activity
pmqs commentedon Feb 13, 2020
here is the equivalent OO
There is no public interface to access the gzip header in
IO::Compress::Gzipbecause I've never seen the need. Can you explain the use-case you want it for?XSven commentedon Feb 13, 2020
To be honest, the OO equivalent disappoints me. I would have expected somethink like
$gz->compress($inputFile);that means an instance(object) method that has one argument, that is the input file.
We could consider this
How do i tell in Perl what the size of a file inside a gzip archive is without unpacking the whole file?
or the question: What is the equivalent of
gzip --listas a use-case? But our use-case that has brought us to the above stackoverflow article was this:We have used the functional interface of
IO::Compress::Gzipto zip an input file. Due to a race condition (a bug at our end:-() there was a discrepancy between the content of the original input file and the zip file. The zip file was not(!) corrupt but after unzipping the zip file it was different from original input file due to the race condition. We thought it would be a good idea to log the compressed and the uncompressed file size (ISIZE) from the perspective of IO::Compress::Gzip. We don't wanted to make extra stat() calls before and/or after the crompress action. We wanted the compress action(object) to provide a feedback.Thx