$title$title
The administrator needs to install the IO::Compress::Gzip Perl module
to support gzipped mboxes.
Return to index
EOF
$fh->close;
}
1;
# fh may not be a proper IO, so we wrap the write and close methods
# to prevent IO::Compress::Gzip from complaining
package PublicInbox::MboxGz;
use strict;
use warnings;
sub new {
my ($class, $fh) = @_;
my $buf;
bless {
buf => \$buf,
gz => IO::Compress::Gzip->new(\$buf),
fh => $fh,
}, $class;
}
sub _flush_buf {
my ($self) = @_;
if (defined ${$self->{buf}}) {
$self->{fh}->write(${$self->{buf}});
${$self->{buf}} = undef;
}
}
sub write {
$_[0]->{gz}->write($_[1]);
_flush_buf($_[0]);
}
sub close {
my ($self) = @_;
$self->{gz}->close;
_flush_buf($self);
$self->{fh}->close;
}
1;