$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;
+use fields qw(gz fh buf);
+
+sub new {
+ my ($class, $fh) = @_;
+ my $self = fields::new($class);
+ my $buf;
+ $self->{buf} = \$buf;
+ $self->{gz} = IO::Compress::Gzip->new(\$buf);
+ $self->{fh} = $fh;
+ $self;
+}
+
+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;