From 83e8f377ad4fd99bab6da6eca0228762bc4e630e Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 22 Apr 2018 10:10:53 +0100 Subject: Support compression on output stream --- utils/split-messages.pl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'utils/split-messages.pl') 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}; -- cgit v1.2.3