require Exporter ;
-use IO::Compress::RawDeflate 2.074 () ;
-use IO::Compress::Adapter::Deflate 2.074 ;
+use IO::Compress::RawDeflate 2.081 () ;
+use IO::Compress::Adapter::Deflate 2.081 ;
-use IO::Compress::Base::Common 2.074 qw(:Status );
-use IO::Compress::Gzip::Constants 2.074 ;
-use IO::Compress::Zlib::Extra 2.074 ;
+use IO::Compress::Base::Common 2.081 qw(:Status );
+use IO::Compress::Gzip::Constants 2.081 ;
+use IO::Compress::Zlib::Extra 2.081 ;
BEGIN
{
our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $GzipError);
-$VERSION = '2.074';
+$VERSION = '2.081';
$GzipError = '' ;
@ISA = qw(IO::Compress::RawDeflate Exporter);
=head1 NAME
IO::Compress::Gzip - Write RFC 1952 files/buffers
-
-
=head1 SYNOPSIS
use IO::Compress::Gzip qw(gzip $GzipError) ;
- my $status = gzip $input => $output [,OPTS]
+ my $status = gzip $input => $output [,OPTS]
or die "gzip failed: $GzipError\n";
my $z = new IO::Compress::Gzip $output [,OPTS]
$z->autoflush();
$z->input_line_number();
$z->newStream( [OPTS] );
-
+
$z->deflateParams();
-
+
$z->close() ;
$GzipError ;
binmode $z
fileno $z
close $z ;
-
+
=head1 DESCRIPTION
All the gzip headers defined in RFC 1952 can be created using
this module.
-For reading RFC 1952 files/buffers, see the companion module
+For reading RFC 1952 files/buffers, see the companion module
L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip>.
=head1 Functional Interface
use IO::Compress::Gzip qw(gzip $GzipError) ;
- gzip $input_filename_or_reference => $output_filename_or_reference [,OPTS]
+ gzip $input_filename_or_reference => $output_filename_or_reference [,OPTS]
or die "gzip failed: $GzipError\n";
The functional interface needs Perl5.005 or better.
=head3 The C<$input_filename_or_reference> parameter
The parameter, C<$input_filename_or_reference>, is used to define the
-source of the uncompressed data.
+source of the uncompressed data.
It can take one of the following forms:
data will be read from it. The string '-' can be used as an alias for
standard input.
-=item A scalar reference
+=item A scalar reference
If C<$input_filename_or_reference> is a scalar reference, the input data
will be read from C<$$input_filename_or_reference>.
-=item An array reference
+=item An array reference
If C<$input_filename_or_reference> is an array reference, each element in
the array must be a filename.
-The input data will be read from each file in turn.
+The input data will be read from each file in turn.
The complete array will be walked to ensure that it only
contains valid filenames before any data is compressed.
=item An Input FileGlob string
If C<$input_filename_or_reference> is a string that is delimited by the
-characters "<" and ">" C<gzip> will assume that it is an
-I<input fileglob string>. The input is the list of files that match the
+characters "<" and ">" C<gzip> will assume that it is an
+I<input fileglob string>. The input is the list of files that match the
fileglob.
See L<File::GlobMapper|File::GlobMapper> for more details.
If the C<$input_filename_or_reference> parameter is any other type,
C<undef> will be returned.
-In addition, if C<$input_filename_or_reference> is a simple filename,
+In addition, if C<$input_filename_or_reference> is a simple filename,
the default values for
the C<Name> and C<Time> options will be sourced from that file.
=item A filename
If the C<$output_filename_or_reference> parameter is a simple scalar, it is
-assumed to be a filename. This file will be opened for writing and the
+assumed to be a filename. This file will be opened for writing and the
compressed data will be written to it.
=item A filehandle
compressed data will be written to it. The string '-' can be used as
an alias for standard output.
-=item A scalar reference
+=item A scalar reference
If C<$output_filename_or_reference> is a scalar reference, the
compressed data will be stored in C<$$output_filename_or_reference>.
=item An Array Reference
-If C<$output_filename_or_reference> is an array reference,
+If C<$output_filename_or_reference> is an array reference,
the compressed data will be pushed onto the array.
=item An Output FileGlob
=item C<< AutoClose => 0|1 >>
-This option applies to any input or output data streams to
+This option applies to any input or output data streams to
C<gzip> that are filehandles.
If C<AutoClose> is specified, and the value is true, it will result in all
=back
-When C<Append> is specified, and set to true, it will I<append> all compressed
+When C<Append> is specified, and set to true, it will I<append> all compressed
data to the output data stream.
So when the output is a filehandle it will carry out a seek to the eof
my $input = new IO::File "<file1.txt"
or die "Cannot open 'file1.txt': $!\n" ;
my $buffer ;
- gzip $input => \$buffer
+ gzip $input => \$buffer
or die "gzip failed: $GzipError\n";
To compress all files in the directory "/my/home" that match "*.txt"
for my $input ( glob "/my/home/*.txt" )
{
my $output = "$input.gz" ;
- gzip $input => $output
+ gzip $input => $output
or die "Error compressing '$input': $GzipError\n";
}
my $z = new IO::Compress::Gzip $output [,OPTS]
or die "IO::Compress::Gzip failed: $GzipError\n";
-It returns an C<IO::Compress::Gzip> object on success and undef on failure.
+It returns an C<IO::Compress::Gzip> object on success and undef on failure.
The variable C<$GzipError> will contain an error message on failure.
-If you are running Perl 5.005 or better the object, C<$z>, returned from
-IO::Compress::Gzip can be used exactly like an L<IO::File|IO::File> filehandle.
-This means that all normal output file operations can be carried out
-with C<$z>.
-For example, to write to a compressed file/buffer you can use either of
+If you are running Perl 5.005 or better the object, C<$z>, returned from
+IO::Compress::Gzip can be used exactly like an L<IO::File|IO::File> filehandle.
+This means that all normal output file operations can be carried out
+with C<$z>.
+For example, to write to a compressed file/buffer you can use either of
these forms
$z->print("hello world\n");
written to it.
The string '-' can be used as an alias for standard output.
-=item A scalar reference
+=item A scalar reference
If C<$output> is a scalar reference, the compressed data will be stored
in C<$$output>.
=item C<< Append => 0|1 >>
-Opens C<$output> in append mode.
+Opens C<$output> in append mode.
The behaviour of this option is dependent on the type of C<$output>.
This option is used to compress input data and append it to an existing
compressed data stream in C<$output>. The end result is a single compressed
-data stream stored in C<$output>.
+data stream stored in C<$output>.
It is a fatal error to attempt to use this option when C<$output> is not an
RFC 1952 data stream.
There are a number of other limitations with the C<Merge> option:
-=over 5
+=over 5
=item 1
This module needs to have been built with zlib 1.2.1 or better to work. A
fatal error will be thrown if C<Merge> is used with an older version of
-zlib.
+zlib.
=item 2
This parameter defaults to 0.
-=item -Level
+=item -Level
Defines the compression level used by zlib. The value should either be
a number between 0 and 9 (0 means no compression and 9 is maximum
use IO::Compress::Gzip qw(:constants);
use IO::Compress::Gzip qw(:all);
-=item -Strategy
+=item -Strategy
Defines the strategy used to tune the compression. Use one of the symbolic
constants defined below.
compliant gzip header (which is exactly 10 bytes long) as defined in
RFC 1952.
-See the section titled "Compliance" in RFC 1952 for a definition
+See the section titled "Compliance" in RFC 1952 for a definition
of the values used for the fields in the gzip header.
All other parameters that control the content of the gzip header will
header. It is used to signal that the data stored in the gzip file/buffer
is probably text.
-The default is 0.
+The default is 0.
=item C<< HeaderCRC => 0|1 >>
=over 5
-=item *
+=item *
The value supplied with the C<Name> option can only contain ISO 8859-1
characters.
-=item *
+=item *
The value supplied with the C<Comment> option can only contain ISO 8859-1
characters plus line-feed.
The values supplied with the C<-Name> and C<-Comment> options cannot
contain multiple embedded nulls.
-=item *
+=item *
If an C<ExtraField> option is specified and it is a simple scalar,
it must conform to the sub-field structure as defined in RFC 1952.
-=item *
+=item *
If an C<ExtraField> option is specified the second byte of the ID will be
checked in each subfield to ensure that it does not contain the reserved
=over 5
-=item *
+=item *
The value supplied with C<-Name> option can contain
any character except NULL.
-=item *
+=item *
The value supplied with C<-Comment> option can contain any character
except NULL.
consist of the characters up to, but not including, the first embedded
NULL.
-=item *
+=item *
If an C<ExtraField> option is specified and it is a simple scalar, the
structure will not be checked. The only error is if the length is too big.
-=item *
+=item *
The ID header in an C<ExtraField> sub-field can consist of any two bytes.
TODO
-=head1 Methods
+=head1 Methods
=head2 print
$z->opened()
-Returns true if the object currently refers to a opened file/buffer.
+Returns true if the object currently refers to a opened file/buffer.
=head2 autoflush
$z->input_line_number()
$z->input_line_number(EXPR)
-This method always returns C<undef> when compressing.
+This method always returns C<undef> when compressing.
=head2 fileno
$z->close() ;
close $z ;
-Flushes any pending compressed data and then closes the output file/buffer.
+Flushes any pending compressed data and then closes the output file/buffer.
For most versions of Perl this method will be automatically invoked if
the IO::Compress::Gzip object is destroyed (either explicitly or by the
TODO
-=head1 Importing
+=head1 Importing
-A number of symbolic constants are required by some methods in
+A number of symbolic constants are required by some methods in
C<IO::Compress::Gzip>. None are imported by default.
=over 5
Z_FIXED
Z_DEFAULT_STRATEGY
-
-
-
=back
=head1 EXAMPLES
L<Archive::Tar|Archive::Tar>,
L<IO::Zlib|IO::Zlib>
-For RFC 1950, 1951 and 1952 see
+For RFC 1950, 1951 and 1952 see
L<http://www.faqs.org/rfcs/rfc1950.html>,
L<http://www.faqs.org/rfcs/rfc1951.html> and
L<http://www.faqs.org/rfcs/rfc1952.html>
=head1 AUTHOR
-This module was written by Paul Marquess, C<pmqs@cpan.org>.
+This module was written by Paul Marquess, C<pmqs@cpan.org>.
=head1 MODIFICATION HISTORY
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2005-2017 Paul Marquess. All rights reserved.
+Copyright (c) 2005-2018 Paul Marquess. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.