summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2018-04-22 10:10:53 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2018-04-22 10:11:11 +0100
commit83e8f377ad4fd99bab6da6eca0228762bc4e630e (patch)
tree01e3e88fb74f87017b87a39082c6fdec0dade8ed
parent42f5bb6182f90313eceb3c1b60bfd4792bbba3d5 (diff)
downloadnetsurf-83e8f377ad4fd99bab6da6eca0228762bc4e630e.tar.gz
netsurf-83e8f377ad4fd99bab6da6eca0228762bc4e630e.tar.bz2
Support compression on output stream
-rw-r--r--utils/split-messages.pl17
1 files changed, 16 insertions, 1 deletions
diff --git a/utils/split-messages.pl b/utils/split-messages.pl
index 570ae03ca..4b50dded8 100644
--- a/utils/split-messages.pl
+++ b/utils/split-messages.pl
@@ -34,6 +34,8 @@ use strict;
use Getopt::Long ();
use Fcntl qw( O_CREAT O_EXCL O_WRONLY O_APPEND O_RDONLY O_WRONLY );
+use IO::Compress::Gzip;
+
use constant GETOPT_OPTS => qw( auto_abbrev no_getopt_compat bundling );
use constant GETOPT_SPEC =>
qw( output|o=s
@@ -43,6 +45,7 @@ use constant GETOPT_SPEC =>
plat|platform|p=s
format|fmt|f=s
warning|W=s
+ gzip|z
help|h|? );
# default option values:
@@ -214,7 +217,7 @@ sub input_stream ()
return \*STDIN;
}
-sub output_stream ()
+sub underlying_output_stream ()
{
if( $opt{output} )
{
@@ -229,6 +232,18 @@ sub output_stream ()
return \*STDOUT;
}
+sub output_stream ()
+{
+ my $ofh = underlying_output_stream();
+
+ if( $opt{gzip} )
+ {
+ $ofh = new IO::Compress::Gzip( $ofh, AutoClose => 1, -Level => 9 );
+ }
+
+ return $ofh;
+}
+
sub formatter ()
{
my $name = $opt{format};