| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "IO::Uncompress::RawInflate 3perl" |
| 58 |
.TH IO::Uncompress::RawInflate 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide" |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
IO::Uncompress::RawInflate \- Read RFC 1951 files/buffers |
| 65 |
.SH SYNOPSIS |
| 66 |
.IX Header "SYNOPSIS" |
| 67 |
.Vb 1 |
| 68 |
\& use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ; |
| 69 |
\& |
| 70 |
\& my $status = rawinflate $input => $output [,OPTS] |
| 71 |
\& or die "rawinflate failed: $RawInflateError\en"; |
| 72 |
\& |
| 73 |
\& my $z = IO::Uncompress::RawInflate\->new( $input [OPTS] ) |
| 74 |
\& or die "rawinflate failed: $RawInflateError\en"; |
| 75 |
\& |
| 76 |
\& $status = $z\->read($buffer) |
| 77 |
\& $status = $z\->read($buffer, $length) |
| 78 |
\& $status = $z\->read($buffer, $length, $offset) |
| 79 |
\& $line = $z\->getline() |
| 80 |
\& $char = $z\->getc() |
| 81 |
\& $char = $z\->ungetc() |
| 82 |
\& $char = $z\->opened() |
| 83 |
\& |
| 84 |
\& $status = $z\->inflateSync() |
| 85 |
\& |
| 86 |
\& $data = $z\->trailingData() |
| 87 |
\& $status = $z\->nextStream() |
| 88 |
\& $data = $z\->getHeaderInfo() |
| 89 |
\& $z\->tell() |
| 90 |
\& $z\->seek($position, $whence) |
| 91 |
\& $z\->binmode() |
| 92 |
\& $z\->fileno() |
| 93 |
\& $z\->eof() |
| 94 |
\& $z\->close() |
| 95 |
\& |
| 96 |
\& $RawInflateError ; |
| 97 |
\& |
| 98 |
\& # IO::File mode |
| 99 |
\& |
| 100 |
\& <$z> |
| 101 |
\& read($z, $buffer); |
| 102 |
\& read($z, $buffer, $length); |
| 103 |
\& read($z, $buffer, $length, $offset); |
| 104 |
\& tell($z) |
| 105 |
\& seek($z, $position, $whence) |
| 106 |
\& binmode($z) |
| 107 |
\& fileno($z) |
| 108 |
\& eof($z) |
| 109 |
\& close($z) |
| 110 |
.Ve |
| 111 |
.SH DESCRIPTION |
| 112 |
.IX Header "DESCRIPTION" |
| 113 |
This module provides a Perl interface that allows the reading of |
| 114 |
files/buffers that conform to RFC 1951. |
| 115 |
.PP |
| 116 |
For writing RFC 1951 files/buffers, see the companion module IO::Compress::RawDeflate. |
| 117 |
.SH "Functional Interface" |
| 118 |
.IX Header "Functional Interface" |
| 119 |
A top-level function, \f(CW\*(C`rawinflate\*(C'\fR, is provided to carry out |
| 120 |
"one-shot" uncompression between buffers and/or files. For finer |
| 121 |
control over the uncompression process, see the "OO Interface" |
| 122 |
section. |
| 123 |
.PP |
| 124 |
.Vb 1 |
| 125 |
\& use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ; |
| 126 |
\& |
| 127 |
\& rawinflate $input_filename_or_reference => $output_filename_or_reference [,OPTS] |
| 128 |
\& or die "rawinflate failed: $RawInflateError\en"; |
| 129 |
.Ve |
| 130 |
.PP |
| 131 |
The functional interface needs Perl5.005 or better. |
| 132 |
.ie n .SS "rawinflate $input_filename_or_reference => $output_filename_or_reference [, OPTS]" |
| 133 |
.el .SS "rawinflate \f(CW$input_filename_or_reference\fP => \f(CW$output_filename_or_reference\fP [, OPTS]" |
| 134 |
.IX Subsection "rawinflate $input_filename_or_reference => $output_filename_or_reference [, OPTS]" |
| 135 |
\&\f(CW\*(C`rawinflate\*(C'\fR expects at least two parameters, |
| 136 |
\&\f(CW$input_filename_or_reference\fR and \f(CW$output_filename_or_reference\fR |
| 137 |
and zero or more optional parameters (see "Optional Parameters") |
| 138 |
.PP |
| 139 |
\fIThe \fR\f(CI$input_filename_or_reference\fR\fI parameter\fR |
| 140 |
.IX Subsection "The $input_filename_or_reference parameter" |
| 141 |
.PP |
| 142 |
The parameter, \f(CW$input_filename_or_reference\fR, is used to define the |
| 143 |
source of the compressed data. |
| 144 |
.PP |
| 145 |
It can take one of the following forms: |
| 146 |
.IP "A filename" 5 |
| 147 |
.IX Item "A filename" |
| 148 |
If the \f(CW$input_filename_or_reference\fR parameter is a simple scalar, it is |
| 149 |
assumed to be a filename. This file will be opened for reading and the |
| 150 |
input data will be read from it. |
| 151 |
.IP "A filehandle" 5 |
| 152 |
.IX Item "A filehandle" |
| 153 |
If the \f(CW$input_filename_or_reference\fR parameter is a filehandle, the input |
| 154 |
data will be read from it. The string '\-' can be used as an alias for |
| 155 |
standard input. |
| 156 |
.IP "A scalar reference" 5 |
| 157 |
.IX Item "A scalar reference" |
| 158 |
If \f(CW$input_filename_or_reference\fR is a scalar reference, the input data |
| 159 |
will be read from \f(CW$$input_filename_or_reference\fR. |
| 160 |
.IP "An array reference" 5 |
| 161 |
.IX Item "An array reference" |
| 162 |
If \f(CW$input_filename_or_reference\fR is an array reference, each element in |
| 163 |
the array must be a filename. |
| 164 |
.Sp |
| 165 |
The input data will be read from each file in turn. |
| 166 |
.Sp |
| 167 |
The complete array will be walked to ensure that it only |
| 168 |
contains valid filenames before any data is uncompressed. |
| 169 |
.IP "An Input FileGlob string" 5 |
| 170 |
.IX Item "An Input FileGlob string" |
| 171 |
If \f(CW$input_filename_or_reference\fR is a string that is delimited by the |
| 172 |
characters "<" and ">" \f(CW\*(C`rawinflate\*(C'\fR will assume that it is an |
| 173 |
\&\fIinput fileglob string\fR. The input is the list of files that match the |
| 174 |
fileglob. |
| 175 |
.Sp |
| 176 |
See File::GlobMapper for more details. |
| 177 |
.PP |
| 178 |
If the \f(CW$input_filename_or_reference\fR parameter is any other type, |
| 179 |
\&\f(CW\*(C`undef\*(C'\fR will be returned. |
| 180 |
.PP |
| 181 |
\fIThe \fR\f(CI$output_filename_or_reference\fR\fI parameter\fR |
| 182 |
.IX Subsection "The $output_filename_or_reference parameter" |
| 183 |
.PP |
| 184 |
The parameter \f(CW$output_filename_or_reference\fR is used to control the |
| 185 |
destination of the uncompressed data. This parameter can take one of |
| 186 |
these forms. |
| 187 |
.IP "A filename" 5 |
| 188 |
.IX Item "A filename" |
| 189 |
If the \f(CW$output_filename_or_reference\fR parameter is a simple scalar, it is |
| 190 |
assumed to be a filename. This file will be opened for writing and the |
| 191 |
uncompressed data will be written to it. |
| 192 |
.IP "A filehandle" 5 |
| 193 |
.IX Item "A filehandle" |
| 194 |
If the \f(CW$output_filename_or_reference\fR parameter is a filehandle, the |
| 195 |
uncompressed data will be written to it. The string '\-' can be used as |
| 196 |
an alias for standard output. |
| 197 |
.IP "A scalar reference" 5 |
| 198 |
.IX Item "A scalar reference" |
| 199 |
If \f(CW$output_filename_or_reference\fR is a scalar reference, the |
| 200 |
uncompressed data will be stored in \f(CW$$output_filename_or_reference\fR. |
| 201 |
.IP "An Array Reference" 5 |
| 202 |
.IX Item "An Array Reference" |
| 203 |
If \f(CW$output_filename_or_reference\fR is an array reference, |
| 204 |
the uncompressed data will be pushed onto the array. |
| 205 |
.IP "An Output FileGlob" 5 |
| 206 |
.IX Item "An Output FileGlob" |
| 207 |
If \f(CW$output_filename_or_reference\fR is a string that is delimited by the |
| 208 |
characters "<" and ">" \f(CW\*(C`rawinflate\*(C'\fR will assume that it is an |
| 209 |
\&\fIoutput fileglob string\fR. The output is the list of files that match the |
| 210 |
fileglob. |
| 211 |
.Sp |
| 212 |
When \f(CW$output_filename_or_reference\fR is an fileglob string, |
| 213 |
\&\f(CW$input_filename_or_reference\fR must also be a fileglob string. Anything |
| 214 |
else is an error. |
| 215 |
.Sp |
| 216 |
See File::GlobMapper for more details. |
| 217 |
.PP |
| 218 |
If the \f(CW$output_filename_or_reference\fR parameter is any other type, |
| 219 |
\&\f(CW\*(C`undef\*(C'\fR will be returned. |
| 220 |
.SS Notes |
| 221 |
.IX Subsection "Notes" |
| 222 |
When \f(CW$input_filename_or_reference\fR maps to multiple compressed |
| 223 |
files/buffers and \f(CW$output_filename_or_reference\fR is |
| 224 |
a single file/buffer, after uncompression \f(CW$output_filename_or_reference\fR will contain a |
| 225 |
concatenation of all the uncompressed data from each of the input |
| 226 |
files/buffers. |
| 227 |
.SS "Optional Parameters" |
| 228 |
.IX Subsection "Optional Parameters" |
| 229 |
The optional parameters for the one-shot function \f(CW\*(C`rawinflate\*(C'\fR |
| 230 |
are (for the most part) identical to those used with the OO interface defined in the |
| 231 |
"Constructor Options" section. The exceptions are listed below |
| 232 |
.ie n .IP """AutoClose => 0|1""" 5 |
| 233 |
.el .IP "\f(CWAutoClose => 0|1\fR" 5 |
| 234 |
.IX Item "AutoClose => 0|1" |
| 235 |
This option applies to any input or output data streams to |
| 236 |
\&\f(CW\*(C`rawinflate\*(C'\fR that are filehandles. |
| 237 |
.Sp |
| 238 |
If \f(CW\*(C`AutoClose\*(C'\fR is specified, and the value is true, it will result in all |
| 239 |
input and/or output filehandles being closed once \f(CW\*(C`rawinflate\*(C'\fR has |
| 240 |
completed. |
| 241 |
.Sp |
| 242 |
This parameter defaults to 0. |
| 243 |
.ie n .IP """BinModeOut => 0|1""" 5 |
| 244 |
.el .IP "\f(CWBinModeOut => 0|1\fR" 5 |
| 245 |
.IX Item "BinModeOut => 0|1" |
| 246 |
This option is now a no-op. All files will be written in binmode. |
| 247 |
.ie n .IP """Append => 0|1""" 5 |
| 248 |
.el .IP "\f(CWAppend => 0|1\fR" 5 |
| 249 |
.IX Item "Append => 0|1" |
| 250 |
The behaviour of this option is dependent on the type of output data |
| 251 |
stream. |
| 252 |
.RS 5 |
| 253 |
.IP \(bu 5 |
| 254 |
A Buffer |
| 255 |
.Sp |
| 256 |
If \f(CW\*(C`Append\*(C'\fR is enabled, all uncompressed data will be append to the end of |
| 257 |
the output buffer. Otherwise the output buffer will be cleared before any |
| 258 |
uncompressed data is written to it. |
| 259 |
.IP \(bu 5 |
| 260 |
A Filename |
| 261 |
.Sp |
| 262 |
If \f(CW\*(C`Append\*(C'\fR is enabled, the file will be opened in append mode. Otherwise |
| 263 |
the contents of the file, if any, will be truncated before any uncompressed |
| 264 |
data is written to it. |
| 265 |
.IP \(bu 5 |
| 266 |
A Filehandle |
| 267 |
.Sp |
| 268 |
If \f(CW\*(C`Append\*(C'\fR is enabled, the filehandle will be positioned to the end of |
| 269 |
the file via a call to \f(CW\*(C`seek\*(C'\fR before any uncompressed data is |
| 270 |
written to it. Otherwise the file pointer will not be moved. |
| 271 |
.RE |
| 272 |
.RS 5 |
| 273 |
.Sp |
| 274 |
When \f(CW\*(C`Append\*(C'\fR is specified, and set to true, it will \fIappend\fR all uncompressed |
| 275 |
data to the output data stream. |
| 276 |
.Sp |
| 277 |
So when the output is a filehandle it will carry out a seek to the eof |
| 278 |
before writing any uncompressed data. If the output is a filename, it will be opened for |
| 279 |
appending. If the output is a buffer, all uncompressed data will be |
| 280 |
appended to the existing buffer. |
| 281 |
.Sp |
| 282 |
Conversely when \f(CW\*(C`Append\*(C'\fR is not specified, or it is present and is set to |
| 283 |
false, it will operate as follows. |
| 284 |
.Sp |
| 285 |
When the output is a filename, it will truncate the contents of the file |
| 286 |
before writing any uncompressed data. If the output is a filehandle |
| 287 |
its position will not be changed. If the output is a buffer, it will be |
| 288 |
wiped before any uncompressed data is output. |
| 289 |
.Sp |
| 290 |
Defaults to 0. |
| 291 |
.RE |
| 292 |
.ie n .IP """MultiStream => 0|1""" 5 |
| 293 |
.el .IP "\f(CWMultiStream => 0|1\fR" 5 |
| 294 |
.IX Item "MultiStream => 0|1" |
| 295 |
This option is a no-op. |
| 296 |
.ie n .IP """TrailingData => $scalar""" 5 |
| 297 |
.el .IP "\f(CWTrailingData => $scalar\fR" 5 |
| 298 |
.IX Item "TrailingData => $scalar" |
| 299 |
Returns the data, if any, that is present immediately after the compressed |
| 300 |
data stream once uncompression is complete. |
| 301 |
.Sp |
| 302 |
This option can be used when there is useful information immediately |
| 303 |
following the compressed data stream, and you don't know the length of the |
| 304 |
compressed data stream. |
| 305 |
.Sp |
| 306 |
If the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from the |
| 307 |
end of the compressed data stream to the end of the buffer. |
| 308 |
.Sp |
| 309 |
If the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that is |
| 310 |
left in the filehandle input buffer once the end of the compressed data |
| 311 |
stream has been reached. You can then use the filehandle to read the rest |
| 312 |
of the input file. |
| 313 |
.Sp |
| 314 |
Don't bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename. |
| 315 |
.Sp |
| 316 |
If you know the length of the compressed data stream before you start |
| 317 |
uncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the |
| 318 |
\&\f(CW\*(C`InputLength\*(C'\fR option. |
| 319 |
.SS "OneShot Examples" |
| 320 |
.IX Subsection "OneShot Examples" |
| 321 |
To read the contents of the file \f(CW\*(C`file1.txt.1951\*(C'\fR and write the |
| 322 |
uncompressed data to the file \f(CW\*(C`file1.txt\*(C'\fR. |
| 323 |
.PP |
| 324 |
.Vb 3 |
| 325 |
\& use strict ; |
| 326 |
\& use warnings ; |
| 327 |
\& use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ; |
| 328 |
\& |
| 329 |
\& my $input = "file1.txt.1951"; |
| 330 |
\& my $output = "file1.txt"; |
| 331 |
\& rawinflate $input => $output |
| 332 |
\& or die "rawinflate failed: $RawInflateError\en"; |
| 333 |
.Ve |
| 334 |
.PP |
| 335 |
To read from an existing Perl filehandle, \f(CW$input\fR, and write the |
| 336 |
uncompressed data to a buffer, \f(CW$buffer\fR. |
| 337 |
.PP |
| 338 |
.Vb 4 |
| 339 |
\& use strict ; |
| 340 |
\& use warnings ; |
| 341 |
\& use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ; |
| 342 |
\& use IO::File ; |
| 343 |
\& |
| 344 |
\& my $input = IO::File\->new( "<file1.txt.1951" ) |
| 345 |
\& or die "Cannot open \*(Aqfile1.txt.1951\*(Aq: $!\en" ; |
| 346 |
\& my $buffer ; |
| 347 |
\& rawinflate $input => \e$buffer |
| 348 |
\& or die "rawinflate failed: $RawInflateError\en"; |
| 349 |
.Ve |
| 350 |
.PP |
| 351 |
To uncompress all files in the directory "/my/home" that match "*.txt.1951" and store the compressed data in the same directory |
| 352 |
.PP |
| 353 |
.Vb 3 |
| 354 |
\& use strict ; |
| 355 |
\& use warnings ; |
| 356 |
\& use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ; |
| 357 |
\& |
| 358 |
\& rawinflate \*(Aq</my/home/*.txt.1951>\*(Aq => \*(Aq</my/home/#1.txt>\*(Aq |
| 359 |
\& or die "rawinflate failed: $RawInflateError\en"; |
| 360 |
.Ve |
| 361 |
.PP |
| 362 |
and if you want to compress each file one at a time, this will do the trick |
| 363 |
.PP |
| 364 |
.Vb 3 |
| 365 |
\& use strict ; |
| 366 |
\& use warnings ; |
| 367 |
\& use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ; |
| 368 |
\& |
| 369 |
\& for my $input ( glob "/my/home/*.txt.1951" ) |
| 370 |
\& { |
| 371 |
\& my $output = $input; |
| 372 |
\& $output =~ s/.1951// ; |
| 373 |
\& rawinflate $input => $output |
| 374 |
\& or die "Error compressing \*(Aq$input\*(Aq: $RawInflateError\en"; |
| 375 |
\& } |
| 376 |
.Ve |
| 377 |
.SH "OO Interface" |
| 378 |
.IX Header "OO Interface" |
| 379 |
.SS Constructor |
| 380 |
.IX Subsection "Constructor" |
| 381 |
The format of the constructor for IO::Uncompress::RawInflate is shown below |
| 382 |
.PP |
| 383 |
.Vb 2 |
| 384 |
\& my $z = IO::Uncompress::RawInflate\->new( $input [OPTS] ) |
| 385 |
\& or die "IO::Uncompress::RawInflate failed: $RawInflateError\en"; |
| 386 |
.Ve |
| 387 |
.PP |
| 388 |
The constructor takes one mandatory parameter, \f(CW$input\fR, defined below, and |
| 389 |
zero or more \f(CW\*(C`OPTS\*(C'\fR, defined in "Constructor Options". |
| 390 |
.PP |
| 391 |
Returns an \f(CW\*(C`IO::Uncompress::RawInflate\*(C'\fR object on success and undef on failure. |
| 392 |
The variable \f(CW$RawInflateError\fR will contain an error message on failure. |
| 393 |
.PP |
| 394 |
If you are running Perl 5.005 or better the object, \f(CW$z\fR, returned from |
| 395 |
IO::Uncompress::RawInflate can be used exactly like an IO::File filehandle. |
| 396 |
This means that all normal input file operations can be carried out with |
| 397 |
\&\f(CW$z\fR. For example, to read a line from a compressed file/buffer you can |
| 398 |
use either of these forms |
| 399 |
.PP |
| 400 |
.Vb 2 |
| 401 |
\& $line = $z\->getline(); |
| 402 |
\& $line = <$z>; |
| 403 |
.Ve |
| 404 |
.PP |
| 405 |
Below is a simple exaple of using the OO interface to read the compressed file |
| 406 |
\&\f(CW\*(C`myfile.1951\*(C'\fR and write its contents to stdout. |
| 407 |
.PP |
| 408 |
.Vb 3 |
| 409 |
\& my $filename = "myfile.1951"; |
| 410 |
\& my $z = IO::Uncompress::RawInflate\->new($filename) |
| 411 |
\& or die "IO::Uncompress::RawInflate failed: $RawInflateError\en"; |
| 412 |
\& |
| 413 |
\& while (<$z>) { |
| 414 |
\& print $_; |
| 415 |
\& } |
| 416 |
\& $z\->close(); |
| 417 |
.Ve |
| 418 |
.PP |
| 419 |
See "EXAMPLES" for further examples |
| 420 |
.PP |
| 421 |
The mandatory parameter \f(CW$input\fR is used to determine the source of the |
| 422 |
compressed data. This parameter can take one of three forms. |
| 423 |
.IP "A filename" 5 |
| 424 |
.IX Item "A filename" |
| 425 |
If the \f(CW$input\fR parameter is a scalar, it is assumed to be a filename. This |
| 426 |
file will be opened for reading and the compressed data will be read from it. |
| 427 |
.IP "A filehandle" 5 |
| 428 |
.IX Item "A filehandle" |
| 429 |
If the \f(CW$input\fR parameter is a filehandle, the compressed data will be |
| 430 |
read from it. |
| 431 |
The string '\-' can be used as an alias for standard input. |
| 432 |
.IP "A scalar reference" 5 |
| 433 |
.IX Item "A scalar reference" |
| 434 |
If \f(CW$input\fR is a scalar reference, the compressed data will be read from |
| 435 |
\&\f(CW$$input\fR. |
| 436 |
.SS "Constructor Options" |
| 437 |
.IX Subsection "Constructor Options" |
| 438 |
The option names defined below are case insensitive and can be optionally |
| 439 |
prefixed by a '\-'. So all of the following are valid |
| 440 |
.PP |
| 441 |
.Vb 4 |
| 442 |
\& \-AutoClose |
| 443 |
\& \-autoclose |
| 444 |
\& AUTOCLOSE |
| 445 |
\& autoclose |
| 446 |
.Ve |
| 447 |
.PP |
| 448 |
OPTS is a combination of the following options: |
| 449 |
.ie n .IP """AutoClose => 0|1""" 5 |
| 450 |
.el .IP "\f(CWAutoClose => 0|1\fR" 5 |
| 451 |
.IX Item "AutoClose => 0|1" |
| 452 |
This option is only valid when the \f(CW$input\fR parameter is a filehandle. If |
| 453 |
specified, and the value is true, it will result in the file being closed once |
| 454 |
either the \f(CW\*(C`close\*(C'\fR method is called or the IO::Uncompress::RawInflate object is |
| 455 |
destroyed. |
| 456 |
.Sp |
| 457 |
This parameter defaults to 0. |
| 458 |
.ie n .IP """MultiStream => 0|1""" 5 |
| 459 |
.el .IP "\f(CWMultiStream => 0|1\fR" 5 |
| 460 |
.IX Item "MultiStream => 0|1" |
| 461 |
Allows multiple concatenated compressed streams to be treated as a single |
| 462 |
compressed stream. Decompression will stop once either the end of the |
| 463 |
file/buffer is reached, an error is encountered (premature eof, corrupt |
| 464 |
compressed data) or the end of a stream is not immediately followed by the |
| 465 |
start of another stream. |
| 466 |
.Sp |
| 467 |
This parameter defaults to 0. |
| 468 |
.ie n .IP """Prime => $string""" 5 |
| 469 |
.el .IP "\f(CWPrime => $string\fR" 5 |
| 470 |
.IX Item "Prime => $string" |
| 471 |
This option will uncompress the contents of \f(CW$string\fR before processing the |
| 472 |
input file/buffer. |
| 473 |
.Sp |
| 474 |
This option can be useful when the compressed data is embedded in another |
| 475 |
file/data structure and it is not possible to work out where the compressed |
| 476 |
data begins without having to read the first few bytes. If this is the |
| 477 |
case, the uncompression can be \fIprimed\fR with these bytes using this |
| 478 |
option. |
| 479 |
.ie n .IP """Transparent => 0|1""" 5 |
| 480 |
.el .IP "\f(CWTransparent => 0|1\fR" 5 |
| 481 |
.IX Item "Transparent => 0|1" |
| 482 |
If this option is set and the input file/buffer is not compressed data, |
| 483 |
the module will allow reading of it anyway. |
| 484 |
.Sp |
| 485 |
In addition, if the input file/buffer does contain compressed data and |
| 486 |
there is non-compressed data immediately following it, setting this option |
| 487 |
will make this module treat the whole file/buffer as a single data stream. |
| 488 |
.Sp |
| 489 |
This option defaults to 1. |
| 490 |
.ie n .IP """BlockSize => $num""" 5 |
| 491 |
.el .IP "\f(CWBlockSize => $num\fR" 5 |
| 492 |
.IX Item "BlockSize => $num" |
| 493 |
When reading the compressed input data, IO::Uncompress::RawInflate will read it in |
| 494 |
blocks of \f(CW$num\fR bytes. |
| 495 |
.Sp |
| 496 |
This option defaults to 4096. |
| 497 |
.ie n .IP """InputLength => $size""" 5 |
| 498 |
.el .IP "\f(CWInputLength => $size\fR" 5 |
| 499 |
.IX Item "InputLength => $size" |
| 500 |
When present this option will limit the number of compressed bytes read |
| 501 |
from the input file/buffer to \f(CW$size\fR. This option can be used in the |
| 502 |
situation where there is useful data directly after the compressed data |
| 503 |
stream and you know beforehand the exact length of the compressed data |
| 504 |
stream. |
| 505 |
.Sp |
| 506 |
This option is mostly used when reading from a filehandle, in which case |
| 507 |
the file pointer will be left pointing to the first byte directly after the |
| 508 |
compressed data stream. |
| 509 |
.Sp |
| 510 |
This option defaults to off. |
| 511 |
.ie n .IP """Append => 0|1""" 5 |
| 512 |
.el .IP "\f(CWAppend => 0|1\fR" 5 |
| 513 |
.IX Item "Append => 0|1" |
| 514 |
This option controls what the \f(CW\*(C`read\*(C'\fR method does with uncompressed data. |
| 515 |
.Sp |
| 516 |
If set to 1, all uncompressed data will be appended to the output parameter |
| 517 |
of the \f(CW\*(C`read\*(C'\fR method. |
| 518 |
.Sp |
| 519 |
If set to 0, the contents of the output parameter of the \f(CW\*(C`read\*(C'\fR method |
| 520 |
will be overwritten by the uncompressed data. |
| 521 |
.Sp |
| 522 |
Defaults to 0. |
| 523 |
.ie n .IP """Strict => 0|1""" 5 |
| 524 |
.el .IP "\f(CWStrict => 0|1\fR" 5 |
| 525 |
.IX Item "Strict => 0|1" |
| 526 |
This option is a no-op. |
| 527 |
.SH Methods |
| 528 |
.IX Header "Methods" |
| 529 |
.SS read |
| 530 |
.IX Subsection "read" |
| 531 |
Usage is |
| 532 |
.PP |
| 533 |
.Vb 1 |
| 534 |
\& $status = $z\->read($buffer) |
| 535 |
.Ve |
| 536 |
.PP |
| 537 |
Reads a block of compressed data (the size of the compressed block is |
| 538 |
determined by the \f(CW\*(C`Buffer\*(C'\fR option in the constructor), uncompresses it and |
| 539 |
writes any uncompressed data into \f(CW$buffer\fR. If the \f(CW\*(C`Append\*(C'\fR parameter is |
| 540 |
set in the constructor, the uncompressed data will be appended to the |
| 541 |
\&\f(CW$buffer\fR parameter. Otherwise \f(CW$buffer\fR will be overwritten. |
| 542 |
.PP |
| 543 |
Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof |
| 544 |
or a negative number on error. |
| 545 |
.SS read |
| 546 |
.IX Subsection "read" |
| 547 |
Usage is |
| 548 |
.PP |
| 549 |
.Vb 2 |
| 550 |
\& $status = $z\->read($buffer, $length) |
| 551 |
\& $status = $z\->read($buffer, $length, $offset) |
| 552 |
\& |
| 553 |
\& $status = read($z, $buffer, $length) |
| 554 |
\& $status = read($z, $buffer, $length, $offset) |
| 555 |
.Ve |
| 556 |
.PP |
| 557 |
Attempt to read \f(CW$length\fR bytes of uncompressed data into \f(CW$buffer\fR. |
| 558 |
.PP |
| 559 |
The main difference between this form of the \f(CW\*(C`read\*(C'\fR method and the |
| 560 |
previous one, is that this one will attempt to return \fIexactly\fR \f(CW$length\fR |
| 561 |
bytes. The only circumstances that this function will not is if end-of-file |
| 562 |
or an IO error is encountered. |
| 563 |
.PP |
| 564 |
Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof |
| 565 |
or a negative number on error. |
| 566 |
.SS getline |
| 567 |
.IX Subsection "getline" |
| 568 |
Usage is |
| 569 |
.PP |
| 570 |
.Vb 2 |
| 571 |
\& $line = $z\->getline() |
| 572 |
\& $line = <$z> |
| 573 |
.Ve |
| 574 |
.PP |
| 575 |
Reads a single line. |
| 576 |
.PP |
| 577 |
This method fully supports the use of the variable \f(CW$/\fR (or |
| 578 |
\&\f(CW$INPUT_RECORD_SEPARATOR\fR or \f(CW$RS\fR when \f(CW\*(C`English\*(C'\fR is in use) to |
| 579 |
determine what constitutes an end of line. Paragraph mode, record mode and |
| 580 |
file slurp mode are all supported. |
| 581 |
.SS getc |
| 582 |
.IX Subsection "getc" |
| 583 |
Usage is |
| 584 |
.PP |
| 585 |
.Vb 1 |
| 586 |
\& $char = $z\->getc() |
| 587 |
.Ve |
| 588 |
.PP |
| 589 |
Read a single character. |
| 590 |
.SS ungetc |
| 591 |
.IX Subsection "ungetc" |
| 592 |
Usage is |
| 593 |
.PP |
| 594 |
.Vb 1 |
| 595 |
\& $char = $z\->ungetc($string) |
| 596 |
.Ve |
| 597 |
.SS inflateSync |
| 598 |
.IX Subsection "inflateSync" |
| 599 |
Usage is |
| 600 |
.PP |
| 601 |
.Vb 1 |
| 602 |
\& $status = $z\->inflateSync() |
| 603 |
.Ve |
| 604 |
.PP |
| 605 |
TODO |
| 606 |
.SS getHeaderInfo |
| 607 |
.IX Subsection "getHeaderInfo" |
| 608 |
Usage is |
| 609 |
.PP |
| 610 |
.Vb 2 |
| 611 |
\& $hdr = $z\->getHeaderInfo(); |
| 612 |
\& @hdrs = $z\->getHeaderInfo(); |
| 613 |
.Ve |
| 614 |
.PP |
| 615 |
This method returns either a hash reference (in scalar context) or a list |
| 616 |
or hash references (in array context) that contains information about each |
| 617 |
of the header fields in the compressed data stream(s). |
| 618 |
.SS tell |
| 619 |
.IX Subsection "tell" |
| 620 |
Usage is |
| 621 |
.PP |
| 622 |
.Vb 2 |
| 623 |
\& $z\->tell() |
| 624 |
\& tell $z |
| 625 |
.Ve |
| 626 |
.PP |
| 627 |
Returns the uncompressed file offset. |
| 628 |
.SS eof |
| 629 |
.IX Subsection "eof" |
| 630 |
Usage is |
| 631 |
.PP |
| 632 |
.Vb 2 |
| 633 |
\& $z\->eof(); |
| 634 |
\& eof($z); |
| 635 |
.Ve |
| 636 |
.PP |
| 637 |
Returns true if the end of the compressed input stream has been reached. |
| 638 |
.SS seek |
| 639 |
.IX Subsection "seek" |
| 640 |
.Vb 2 |
| 641 |
\& $z\->seek($position, $whence); |
| 642 |
\& seek($z, $position, $whence); |
| 643 |
.Ve |
| 644 |
.PP |
| 645 |
Provides a sub-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restriction |
| 646 |
that it is only legal to seek forward in the input file/buffer. |
| 647 |
It is a fatal error to attempt to seek backward. |
| 648 |
.PP |
| 649 |
Note that the implementation of \f(CW\*(C`seek\*(C'\fR in this module does not provide |
| 650 |
true random access to a compressed file/buffer. It works by uncompressing |
| 651 |
data from the current offset in the file/buffer until it reaches the |
| 652 |
uncompressed offset specified in the parameters to \f(CW\*(C`seek\*(C'\fR. For very small |
| 653 |
files this may be acceptable behaviour. For large files it may cause an |
| 654 |
unacceptable delay. |
| 655 |
.PP |
| 656 |
The \f(CW$whence\fR parameter takes one the usual values, namely SEEK_SET, |
| 657 |
SEEK_CUR or SEEK_END. |
| 658 |
.PP |
| 659 |
Returns 1 on success, 0 on failure. |
| 660 |
.SS binmode |
| 661 |
.IX Subsection "binmode" |
| 662 |
Usage is |
| 663 |
.PP |
| 664 |
.Vb 2 |
| 665 |
\& $z\->binmode |
| 666 |
\& binmode $z ; |
| 667 |
.Ve |
| 668 |
.PP |
| 669 |
This is a noop provided for completeness. |
| 670 |
.SS opened |
| 671 |
.IX Subsection "opened" |
| 672 |
.Vb 1 |
| 673 |
\& $z\->opened() |
| 674 |
.Ve |
| 675 |
.PP |
| 676 |
Returns true if the object currently refers to a opened file/buffer. |
| 677 |
.SS autoflush |
| 678 |
.IX Subsection "autoflush" |
| 679 |
.Vb 2 |
| 680 |
\& my $prev = $z\->autoflush() |
| 681 |
\& my $prev = $z\->autoflush(EXPR) |
| 682 |
.Ve |
| 683 |
.PP |
| 684 |
If the \f(CW$z\fR object is associated with a file or a filehandle, this method |
| 685 |
returns the current autoflush setting for the underlying filehandle. If |
| 686 |
\&\f(CW\*(C`EXPR\*(C'\fR is present, and is non-zero, it will enable flushing after every |
| 687 |
write/print operation. |
| 688 |
.PP |
| 689 |
If \f(CW$z\fR is associated with a buffer, this method has no effect and always |
| 690 |
returns \f(CW\*(C`undef\*(C'\fR. |
| 691 |
.PP |
| 692 |
\&\fBNote\fR that the special variable \f(CW$|\fR \fBcannot\fR be used to set or |
| 693 |
retrieve the autoflush setting. |
| 694 |
.SS input_line_number |
| 695 |
.IX Subsection "input_line_number" |
| 696 |
.Vb 2 |
| 697 |
\& $z\->input_line_number() |
| 698 |
\& $z\->input_line_number(EXPR) |
| 699 |
.Ve |
| 700 |
.PP |
| 701 |
Returns the current uncompressed line number. If \f(CW\*(C`EXPR\*(C'\fR is present it has |
| 702 |
the effect of setting the line number. Note that setting the line number |
| 703 |
does not change the current position within the file/buffer being read. |
| 704 |
.PP |
| 705 |
The contents of \f(CW$/\fR are used to determine what constitutes a line |
| 706 |
terminator. |
| 707 |
.SS fileno |
| 708 |
.IX Subsection "fileno" |
| 709 |
.Vb 2 |
| 710 |
\& $z\->fileno() |
| 711 |
\& fileno($z) |
| 712 |
.Ve |
| 713 |
.PP |
| 714 |
If the \f(CW$z\fR object is associated with a file or a filehandle, \f(CW\*(C`fileno\*(C'\fR |
| 715 |
will return the underlying file descriptor. Once the \f(CW\*(C`close\*(C'\fR method is |
| 716 |
called \f(CW\*(C`fileno\*(C'\fR will return \f(CW\*(C`undef\*(C'\fR. |
| 717 |
.PP |
| 718 |
If the \f(CW$z\fR object is associated with a buffer, this method will return |
| 719 |
\&\f(CW\*(C`undef\*(C'\fR. |
| 720 |
.SS close |
| 721 |
.IX Subsection "close" |
| 722 |
.Vb 2 |
| 723 |
\& $z\->close() ; |
| 724 |
\& close $z ; |
| 725 |
.Ve |
| 726 |
.PP |
| 727 |
Closes the output file/buffer. |
| 728 |
.PP |
| 729 |
For most versions of Perl this method will be automatically invoked if |
| 730 |
the IO::Uncompress::RawInflate object is destroyed (either explicitly or by the |
| 731 |
variable with the reference to the object going out of scope). The |
| 732 |
exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In |
| 733 |
these cases, the \f(CW\*(C`close\*(C'\fR method will be called automatically, but |
| 734 |
not until global destruction of all live objects when the program is |
| 735 |
terminating. |
| 736 |
.PP |
| 737 |
Therefore, if you want your scripts to be able to run on all versions |
| 738 |
of Perl, you should call \f(CW\*(C`close\*(C'\fR explicitly and not rely on automatic |
| 739 |
closing. |
| 740 |
.PP |
| 741 |
Returns true on success, otherwise 0. |
| 742 |
.PP |
| 743 |
If the \f(CW\*(C`AutoClose\*(C'\fR option has been enabled when the IO::Uncompress::RawInflate |
| 744 |
object was created, and the object is associated with a file, the |
| 745 |
underlying file will also be closed. |
| 746 |
.SS nextStream |
| 747 |
.IX Subsection "nextStream" |
| 748 |
Usage is |
| 749 |
.PP |
| 750 |
.Vb 1 |
| 751 |
\& my $status = $z\->nextStream(); |
| 752 |
.Ve |
| 753 |
.PP |
| 754 |
Skips to the next compressed data stream in the input file/buffer. If a new |
| 755 |
compressed data stream is found, the eof marker will be cleared and \f(CW$.\fR |
| 756 |
will be reset to 0. |
| 757 |
.PP |
| 758 |
Returns 1 if a new stream was found, 0 if none was found, and \-1 if an |
| 759 |
error was encountered. |
| 760 |
.SS trailingData |
| 761 |
.IX Subsection "trailingData" |
| 762 |
Usage is |
| 763 |
.PP |
| 764 |
.Vb 1 |
| 765 |
\& my $data = $z\->trailingData(); |
| 766 |
.Ve |
| 767 |
.PP |
| 768 |
Returns the data, if any, that is present immediately after the compressed |
| 769 |
data stream once uncompression is complete. It only makes sense to call |
| 770 |
this method once the end of the compressed data stream has been |
| 771 |
encountered. |
| 772 |
.PP |
| 773 |
This option can be used when there is useful information immediately |
| 774 |
following the compressed data stream, and you don't know the length of the |
| 775 |
compressed data stream. |
| 776 |
.PP |
| 777 |
If the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from the |
| 778 |
end of the compressed data stream to the end of the buffer. |
| 779 |
.PP |
| 780 |
If the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that is |
| 781 |
left in the filehandle input buffer once the end of the compressed data |
| 782 |
stream has been reached. You can then use the filehandle to read the rest |
| 783 |
of the input file. |
| 784 |
.PP |
| 785 |
Don't bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename. |
| 786 |
.PP |
| 787 |
If you know the length of the compressed data stream before you start |
| 788 |
uncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the |
| 789 |
\&\f(CW\*(C`InputLength\*(C'\fR option in the constructor. |
| 790 |
.SH Importing |
| 791 |
.IX Header "Importing" |
| 792 |
No symbolic constants are required by IO::Uncompress::RawInflate at present. |
| 793 |
.IP :all 5 |
| 794 |
.IX Item ":all" |
| 795 |
Imports \f(CW\*(C`rawinflate\*(C'\fR and \f(CW$RawInflateError\fR. |
| 796 |
Same as doing this |
| 797 |
.Sp |
| 798 |
.Vb 1 |
| 799 |
\& use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ; |
| 800 |
.Ve |
| 801 |
.SH EXAMPLES |
| 802 |
.IX Header "EXAMPLES" |
| 803 |
.SS "Working with Net::FTP" |
| 804 |
.IX Subsection "Working with Net::FTP" |
| 805 |
See IO::Compress::FAQ |
| 806 |
.SH SUPPORT |
| 807 |
.IX Header "SUPPORT" |
| 808 |
General feedback/questions/bug reports should be sent to |
| 809 |
<https://github.com/pmqs/IO\-Compress/issues> (preferred) or |
| 810 |
<https://rt.cpan.org/Public/Dist/Display.html?Name=IO\-Compress>. |
| 811 |
.SH "SEE ALSO" |
| 812 |
.IX Header "SEE ALSO" |
| 813 |
Compress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip, IO::Compress::Deflate, IO::Uncompress::Inflate, IO::Compress::RawDeflate, IO::Compress::Bzip2, IO::Uncompress::Bunzip2, IO::Compress::Lzma, IO::Uncompress::UnLzma, IO::Compress::Xz, IO::Uncompress::UnXz, IO::Compress::Lzip, IO::Uncompress::UnLzip, IO::Compress::Lzop, IO::Uncompress::UnLzop, IO::Compress::Lzf, IO::Uncompress::UnLzf, IO::Compress::Zstd, IO::Uncompress::UnZstd, IO::Uncompress::AnyInflate, IO::Uncompress::AnyUncompress |
| 814 |
.PP |
| 815 |
IO::Compress::FAQ |
| 816 |
.PP |
| 817 |
File::GlobMapper, Archive::Zip, |
| 818 |
Archive::Tar, |
| 819 |
IO::Zlib |
| 820 |
.PP |
| 821 |
For RFC 1950, 1951 and 1952 see |
| 822 |
<https://datatracker.ietf.org/doc/html/rfc1950>, |
| 823 |
<https://datatracker.ietf.org/doc/html/rfc1951> and |
| 824 |
<https://datatracker.ietf.org/doc/html/rfc1952> |
| 825 |
.PP |
| 826 |
The \fIzlib\fR compression library was written by Jean-loup Gailly |
| 827 |
\&\f(CW\*(C`[email protected]\*(C'\fR and Mark Adler \f(CW\*(C`[email protected]\*(C'\fR. |
| 828 |
.PP |
| 829 |
The primary site for the \fIzlib\fR compression library is |
| 830 |
<http://www.zlib.org>. |
| 831 |
.PP |
| 832 |
The primary site for the \fIzlib-ng\fR compression library is |
| 833 |
<https://github.com/zlib\-ng/zlib\-ng>. |
| 834 |
.PP |
| 835 |
The primary site for gzip is <http://www.gzip.org>. |
| 836 |
.SH AUTHOR |
| 837 |
.IX Header "AUTHOR" |
| 838 |
This module was written by Paul Marquess, \f(CW\*(C`[email protected]\*(C'\fR. |
| 839 |
.SH "MODIFICATION HISTORY" |
| 840 |
.IX Header "MODIFICATION HISTORY" |
| 841 |
See the Changes file. |
| 842 |
.SH "COPYRIGHT AND LICENSE" |
| 843 |
.IX Header "COPYRIGHT AND LICENSE" |
| 844 |
Copyright (c) 2005\-2024 Paul Marquess. All rights reserved. |
| 845 |
.PP |
| 846 |
This program is free software; you can redistribute it and/or |
| 847 |
modify it under the same terms as Perl itself. |