Debian Codegraph @

upstream/debian-unstable/man3/IO::Uncompress::Inflate.3perl

raw
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::Inflate 3perl"
58 .TH IO::Uncompress::Inflate 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::Inflate \- Read RFC 1950 files/buffers
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 .Vb 1
68 \& use IO::Uncompress::Inflate qw(inflate $InflateError) ;
69 \&
70 \& my $status = inflate $input => $output [,OPTS]
71 \& or die "inflate failed: $InflateError\en";
72 \&
73 \& my $z = IO::Uncompress::Inflate\->new( $input [OPTS] )
74 \& or die "inflate failed: $InflateError\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 \& $InflateError ;
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 1950.
115 .PP
116 For writing RFC 1950 files/buffers, see the companion module IO::Compress::Deflate.
117 .SH "Functional Interface"
118 .IX Header "Functional Interface"
119 A top-level function, \f(CW\*(C`inflate\*(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::Inflate qw(inflate $InflateError) ;
126 \&
127 \& inflate $input_filename_or_reference => $output_filename_or_reference [,OPTS]
128 \& or die "inflate failed: $InflateError\en";
129 .Ve
130 .PP
131 The functional interface needs Perl5.005 or better.
132 .ie n .SS "inflate $input_filename_or_reference => $output_filename_or_reference [, OPTS]"
133 .el .SS "inflate \f(CW$input_filename_or_reference\fP => \f(CW$output_filename_or_reference\fP [, OPTS]"
134 .IX Subsection "inflate $input_filename_or_reference => $output_filename_or_reference [, OPTS]"
135 \&\f(CW\*(C`inflate\*(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`inflate\*(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`inflate\*(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`inflate\*(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`inflate\*(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`inflate\*(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 If the input file/buffer contains multiple compressed data streams, this
296 option will uncompress the whole lot as a single data stream.
297 .Sp
298 Defaults to 0.
299 .ie n .IP """TrailingData => $scalar""" 5
300 .el .IP "\f(CWTrailingData => $scalar\fR" 5
301 .IX Item "TrailingData => $scalar"
302 Returns the data, if any, that is present immediately after the compressed
303 data stream once uncompression is complete.
304 .Sp
305 This option can be used when there is useful information immediately
306 following the compressed data stream, and you don't know the length of the
307 compressed data stream.
308 .Sp
309 If the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from the
310 end of the compressed data stream to the end of the buffer.
311 .Sp
312 If the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that is
313 left in the filehandle input buffer once the end of the compressed data
314 stream has been reached. You can then use the filehandle to read the rest
315 of the input file.
316 .Sp
317 Don't bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename.
318 .Sp
319 If you know the length of the compressed data stream before you start
320 uncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the
321 \&\f(CW\*(C`InputLength\*(C'\fR option.
322 .SS "OneShot Examples"
323 .IX Subsection "OneShot Examples"
324 To read the contents of the file \f(CW\*(C`file1.txt.1950\*(C'\fR and write the
325 uncompressed data to the file \f(CW\*(C`file1.txt\*(C'\fR.
326 .PP
327 .Vb 3
328 \& use strict ;
329 \& use warnings ;
330 \& use IO::Uncompress::Inflate qw(inflate $InflateError) ;
331 \&
332 \& my $input = "file1.txt.1950";
333 \& my $output = "file1.txt";
334 \& inflate $input => $output
335 \& or die "inflate failed: $InflateError\en";
336 .Ve
337 .PP
338 To read from an existing Perl filehandle, \f(CW$input\fR, and write the
339 uncompressed data to a buffer, \f(CW$buffer\fR.
340 .PP
341 .Vb 4
342 \& use strict ;
343 \& use warnings ;
344 \& use IO::Uncompress::Inflate qw(inflate $InflateError) ;
345 \& use IO::File ;
346 \&
347 \& my $input = IO::File\->new( "<file1.txt.1950" )
348 \& or die "Cannot open \*(Aqfile1.txt.1950\*(Aq: $!\en" ;
349 \& my $buffer ;
350 \& inflate $input => \e$buffer
351 \& or die "inflate failed: $InflateError\en";
352 .Ve
353 .PP
354 To uncompress all files in the directory "/my/home" that match "*.txt.1950" and store the compressed data in the same directory
355 .PP
356 .Vb 3
357 \& use strict ;
358 \& use warnings ;
359 \& use IO::Uncompress::Inflate qw(inflate $InflateError) ;
360 \&
361 \& inflate \*(Aq</my/home/*.txt.1950>\*(Aq => \*(Aq</my/home/#1.txt>\*(Aq
362 \& or die "inflate failed: $InflateError\en";
363 .Ve
364 .PP
365 and if you want to compress each file one at a time, this will do the trick
366 .PP
367 .Vb 3
368 \& use strict ;
369 \& use warnings ;
370 \& use IO::Uncompress::Inflate qw(inflate $InflateError) ;
371 \&
372 \& for my $input ( glob "/my/home/*.txt.1950" )
373 \& {
374 \& my $output = $input;
375 \& $output =~ s/.1950// ;
376 \& inflate $input => $output
377 \& or die "Error compressing \*(Aq$input\*(Aq: $InflateError\en";
378 \& }
379 .Ve
380 .SH "OO Interface"
381 .IX Header "OO Interface"
382 .SS Constructor
383 .IX Subsection "Constructor"
384 The format of the constructor for IO::Uncompress::Inflate is shown below
385 .PP
386 .Vb 2
387 \& my $z = IO::Uncompress::Inflate\->new( $input [OPTS] )
388 \& or die "IO::Uncompress::Inflate failed: $InflateError\en";
389 .Ve
390 .PP
391 The constructor takes one mandatory parameter, \f(CW$input\fR, defined below, and
392 zero or more \f(CW\*(C`OPTS\*(C'\fR, defined in "Constructor Options".
393 .PP
394 Returns an \f(CW\*(C`IO::Uncompress::Inflate\*(C'\fR object on success and undef on failure.
395 The variable \f(CW$InflateError\fR will contain an error message on failure.
396 .PP
397 If you are running Perl 5.005 or better the object, \f(CW$z\fR, returned from
398 IO::Uncompress::Inflate can be used exactly like an IO::File filehandle.
399 This means that all normal input file operations can be carried out with
400 \&\f(CW$z\fR. For example, to read a line from a compressed file/buffer you can
401 use either of these forms
402 .PP
403 .Vb 2
404 \& $line = $z\->getline();
405 \& $line = <$z>;
406 .Ve
407 .PP
408 Below is a simple exaple of using the OO interface to read the compressed file
409 \&\f(CW\*(C`myfile.1950\*(C'\fR and write its contents to stdout.
410 .PP
411 .Vb 3
412 \& my $filename = "myfile.1950";
413 \& my $z = IO::Uncompress::Inflate\->new($filename)
414 \& or die "IO::Uncompress::Inflate failed: $InflateError\en";
415 \&
416 \& while (<$z>) {
417 \& print $_;
418 \& }
419 \& $z\->close();
420 .Ve
421 .PP
422 See "EXAMPLES" for further examples
423 .PP
424 The mandatory parameter \f(CW$input\fR is used to determine the source of the
425 compressed data. This parameter can take one of three forms.
426 .IP "A filename" 5
427 .IX Item "A filename"
428 If the \f(CW$input\fR parameter is a scalar, it is assumed to be a filename. This
429 file will be opened for reading and the compressed data will be read from it.
430 .IP "A filehandle" 5
431 .IX Item "A filehandle"
432 If the \f(CW$input\fR parameter is a filehandle, the compressed data will be
433 read from it.
434 The string '\-' can be used as an alias for standard input.
435 .IP "A scalar reference" 5
436 .IX Item "A scalar reference"
437 If \f(CW$input\fR is a scalar reference, the compressed data will be read from
438 \&\f(CW$$input\fR.
439 .SS "Constructor Options"
440 .IX Subsection "Constructor Options"
441 The option names defined below are case insensitive and can be optionally
442 prefixed by a '\-'. So all of the following are valid
443 .PP
444 .Vb 4
445 \& \-AutoClose
446 \& \-autoclose
447 \& AUTOCLOSE
448 \& autoclose
449 .Ve
450 .PP
451 OPTS is a combination of the following options:
452 .ie n .IP """AutoClose => 0|1""" 5
453 .el .IP "\f(CWAutoClose => 0|1\fR" 5
454 .IX Item "AutoClose => 0|1"
455 This option is only valid when the \f(CW$input\fR parameter is a filehandle. If
456 specified, and the value is true, it will result in the file being closed once
457 either the \f(CW\*(C`close\*(C'\fR method is called or the IO::Uncompress::Inflate object is
458 destroyed.
459 .Sp
460 This parameter defaults to 0.
461 .ie n .IP """MultiStream => 0|1""" 5
462 .el .IP "\f(CWMultiStream => 0|1\fR" 5
463 .IX Item "MultiStream => 0|1"
464 Allows multiple concatenated compressed streams to be treated as a single
465 compressed stream. Decompression will stop once either the end of the
466 file/buffer is reached, an error is encountered (premature eof, corrupt
467 compressed data) or the end of a stream is not immediately followed by the
468 start of another stream.
469 .Sp
470 This parameter defaults to 0.
471 .ie n .IP """Prime => $string""" 5
472 .el .IP "\f(CWPrime => $string\fR" 5
473 .IX Item "Prime => $string"
474 This option will uncompress the contents of \f(CW$string\fR before processing the
475 input file/buffer.
476 .Sp
477 This option can be useful when the compressed data is embedded in another
478 file/data structure and it is not possible to work out where the compressed
479 data begins without having to read the first few bytes. If this is the
480 case, the uncompression can be \fIprimed\fR with these bytes using this
481 option.
482 .ie n .IP """Transparent => 0|1""" 5
483 .el .IP "\f(CWTransparent => 0|1\fR" 5
484 .IX Item "Transparent => 0|1"
485 If this option is set and the input file/buffer is not compressed data,
486 the module will allow reading of it anyway.
487 .Sp
488 In addition, if the input file/buffer does contain compressed data and
489 there is non-compressed data immediately following it, setting this option
490 will make this module treat the whole file/buffer as a single data stream.
491 .Sp
492 This option defaults to 1.
493 .ie n .IP """BlockSize => $num""" 5
494 .el .IP "\f(CWBlockSize => $num\fR" 5
495 .IX Item "BlockSize => $num"
496 When reading the compressed input data, IO::Uncompress::Inflate will read it in
497 blocks of \f(CW$num\fR bytes.
498 .Sp
499 This option defaults to 4096.
500 .ie n .IP """InputLength => $size""" 5
501 .el .IP "\f(CWInputLength => $size\fR" 5
502 .IX Item "InputLength => $size"
503 When present this option will limit the number of compressed bytes read
504 from the input file/buffer to \f(CW$size\fR. This option can be used in the
505 situation where there is useful data directly after the compressed data
506 stream and you know beforehand the exact length of the compressed data
507 stream.
508 .Sp
509 This option is mostly used when reading from a filehandle, in which case
510 the file pointer will be left pointing to the first byte directly after the
511 compressed data stream.
512 .Sp
513 This option defaults to off.
514 .ie n .IP """Append => 0|1""" 5
515 .el .IP "\f(CWAppend => 0|1\fR" 5
516 .IX Item "Append => 0|1"
517 This option controls what the \f(CW\*(C`read\*(C'\fR method does with uncompressed data.
518 .Sp
519 If set to 1, all uncompressed data will be appended to the output parameter
520 of the \f(CW\*(C`read\*(C'\fR method.
521 .Sp
522 If set to 0, the contents of the output parameter of the \f(CW\*(C`read\*(C'\fR method
523 will be overwritten by the uncompressed data.
524 .Sp
525 Defaults to 0.
526 .ie n .IP """Strict => 0|1""" 5
527 .el .IP "\f(CWStrict => 0|1\fR" 5
528 .IX Item "Strict => 0|1"
529 This option controls whether the extra checks defined below are used when
530 carrying out the decompression. When Strict is on, the extra tests are
531 carried out, when Strict is off they are not.
532 .Sp
533 The default for this option is off.
534 .RS 5
535 .IP 1. 5
536 The ADLER32 checksum field must be present.
537 .IP 2. 5
538 The value of the ADLER32 field read must match the adler32 value of the
539 uncompressed data actually contained in the file.
540 .RE
541 .RS 5
542 .RE
543 .SH Methods
544 .IX Header "Methods"
545 .SS read
546 .IX Subsection "read"
547 Usage is
548 .PP
549 .Vb 1
550 \& $status = $z\->read($buffer)
551 .Ve
552 .PP
553 Reads a block of compressed data (the size of the compressed block is
554 determined by the \f(CW\*(C`Buffer\*(C'\fR option in the constructor), uncompresses it and
555 writes any uncompressed data into \f(CW$buffer\fR. If the \f(CW\*(C`Append\*(C'\fR parameter is
556 set in the constructor, the uncompressed data will be appended to the
557 \&\f(CW$buffer\fR parameter. Otherwise \f(CW$buffer\fR will be overwritten.
558 .PP
559 Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof
560 or a negative number on error.
561 .SS read
562 .IX Subsection "read"
563 Usage is
564 .PP
565 .Vb 2
566 \& $status = $z\->read($buffer, $length)
567 \& $status = $z\->read($buffer, $length, $offset)
568 \&
569 \& $status = read($z, $buffer, $length)
570 \& $status = read($z, $buffer, $length, $offset)
571 .Ve
572 .PP
573 Attempt to read \f(CW$length\fR bytes of uncompressed data into \f(CW$buffer\fR.
574 .PP
575 The main difference between this form of the \f(CW\*(C`read\*(C'\fR method and the
576 previous one, is that this one will attempt to return \fIexactly\fR \f(CW$length\fR
577 bytes. The only circumstances that this function will not is if end-of-file
578 or an IO error is encountered.
579 .PP
580 Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof
581 or a negative number on error.
582 .SS getline
583 .IX Subsection "getline"
584 Usage is
585 .PP
586 .Vb 2
587 \& $line = $z\->getline()
588 \& $line = <$z>
589 .Ve
590 .PP
591 Reads a single line.
592 .PP
593 This method fully supports the use of the variable \f(CW$/\fR (or
594 \&\f(CW$INPUT_RECORD_SEPARATOR\fR or \f(CW$RS\fR when \f(CW\*(C`English\*(C'\fR is in use) to
595 determine what constitutes an end of line. Paragraph mode, record mode and
596 file slurp mode are all supported.
597 .SS getc
598 .IX Subsection "getc"
599 Usage is
600 .PP
601 .Vb 1
602 \& $char = $z\->getc()
603 .Ve
604 .PP
605 Read a single character.
606 .SS ungetc
607 .IX Subsection "ungetc"
608 Usage is
609 .PP
610 .Vb 1
611 \& $char = $z\->ungetc($string)
612 .Ve
613 .SS inflateSync
614 .IX Subsection "inflateSync"
615 Usage is
616 .PP
617 .Vb 1
618 \& $status = $z\->inflateSync()
619 .Ve
620 .PP
621 TODO
622 .SS getHeaderInfo
623 .IX Subsection "getHeaderInfo"
624 Usage is
625 .PP
626 .Vb 2
627 \& $hdr = $z\->getHeaderInfo();
628 \& @hdrs = $z\->getHeaderInfo();
629 .Ve
630 .PP
631 This method returns either a hash reference (in scalar context) or a list
632 or hash references (in array context) that contains information about each
633 of the header fields in the compressed data stream(s).
634 .SS tell
635 .IX Subsection "tell"
636 Usage is
637 .PP
638 .Vb 2
639 \& $z\->tell()
640 \& tell $z
641 .Ve
642 .PP
643 Returns the uncompressed file offset.
644 .SS eof
645 .IX Subsection "eof"
646 Usage is
647 .PP
648 .Vb 2
649 \& $z\->eof();
650 \& eof($z);
651 .Ve
652 .PP
653 Returns true if the end of the compressed input stream has been reached.
654 .SS seek
655 .IX Subsection "seek"
656 .Vb 2
657 \& $z\->seek($position, $whence);
658 \& seek($z, $position, $whence);
659 .Ve
660 .PP
661 Provides a sub-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restriction
662 that it is only legal to seek forward in the input file/buffer.
663 It is a fatal error to attempt to seek backward.
664 .PP
665 Note that the implementation of \f(CW\*(C`seek\*(C'\fR in this module does not provide
666 true random access to a compressed file/buffer. It works by uncompressing
667 data from the current offset in the file/buffer until it reaches the
668 uncompressed offset specified in the parameters to \f(CW\*(C`seek\*(C'\fR. For very small
669 files this may be acceptable behaviour. For large files it may cause an
670 unacceptable delay.
671 .PP
672 The \f(CW$whence\fR parameter takes one the usual values, namely SEEK_SET,
673 SEEK_CUR or SEEK_END.
674 .PP
675 Returns 1 on success, 0 on failure.
676 .SS binmode
677 .IX Subsection "binmode"
678 Usage is
679 .PP
680 .Vb 2
681 \& $z\->binmode
682 \& binmode $z ;
683 .Ve
684 .PP
685 This is a noop provided for completeness.
686 .SS opened
687 .IX Subsection "opened"
688 .Vb 1
689 \& $z\->opened()
690 .Ve
691 .PP
692 Returns true if the object currently refers to a opened file/buffer.
693 .SS autoflush
694 .IX Subsection "autoflush"
695 .Vb 2
696 \& my $prev = $z\->autoflush()
697 \& my $prev = $z\->autoflush(EXPR)
698 .Ve
699 .PP
700 If the \f(CW$z\fR object is associated with a file or a filehandle, this method
701 returns the current autoflush setting for the underlying filehandle. If
702 \&\f(CW\*(C`EXPR\*(C'\fR is present, and is non-zero, it will enable flushing after every
703 write/print operation.
704 .PP
705 If \f(CW$z\fR is associated with a buffer, this method has no effect and always
706 returns \f(CW\*(C`undef\*(C'\fR.
707 .PP
708 \&\fBNote\fR that the special variable \f(CW$|\fR \fBcannot\fR be used to set or
709 retrieve the autoflush setting.
710 .SS input_line_number
711 .IX Subsection "input_line_number"
712 .Vb 2
713 \& $z\->input_line_number()
714 \& $z\->input_line_number(EXPR)
715 .Ve
716 .PP
717 Returns the current uncompressed line number. If \f(CW\*(C`EXPR\*(C'\fR is present it has
718 the effect of setting the line number. Note that setting the line number
719 does not change the current position within the file/buffer being read.
720 .PP
721 The contents of \f(CW$/\fR are used to determine what constitutes a line
722 terminator.
723 .SS fileno
724 .IX Subsection "fileno"
725 .Vb 2
726 \& $z\->fileno()
727 \& fileno($z)
728 .Ve
729 .PP
730 If the \f(CW$z\fR object is associated with a file or a filehandle, \f(CW\*(C`fileno\*(C'\fR
731 will return the underlying file descriptor. Once the \f(CW\*(C`close\*(C'\fR method is
732 called \f(CW\*(C`fileno\*(C'\fR will return \f(CW\*(C`undef\*(C'\fR.
733 .PP
734 If the \f(CW$z\fR object is associated with a buffer, this method will return
735 \&\f(CW\*(C`undef\*(C'\fR.
736 .SS close
737 .IX Subsection "close"
738 .Vb 2
739 \& $z\->close() ;
740 \& close $z ;
741 .Ve
742 .PP
743 Closes the output file/buffer.
744 .PP
745 For most versions of Perl this method will be automatically invoked if
746 the IO::Uncompress::Inflate object is destroyed (either explicitly or by the
747 variable with the reference to the object going out of scope). The
748 exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
749 these cases, the \f(CW\*(C`close\*(C'\fR method will be called automatically, but
750 not until global destruction of all live objects when the program is
751 terminating.
752 .PP
753 Therefore, if you want your scripts to be able to run on all versions
754 of Perl, you should call \f(CW\*(C`close\*(C'\fR explicitly and not rely on automatic
755 closing.
756 .PP
757 Returns true on success, otherwise 0.
758 .PP
759 If the \f(CW\*(C`AutoClose\*(C'\fR option has been enabled when the IO::Uncompress::Inflate
760 object was created, and the object is associated with a file, the
761 underlying file will also be closed.
762 .SS nextStream
763 .IX Subsection "nextStream"
764 Usage is
765 .PP
766 .Vb 1
767 \& my $status = $z\->nextStream();
768 .Ve
769 .PP
770 Skips to the next compressed data stream in the input file/buffer. If a new
771 compressed data stream is found, the eof marker will be cleared and \f(CW$.\fR
772 will be reset to 0.
773 .PP
774 Returns 1 if a new stream was found, 0 if none was found, and \-1 if an
775 error was encountered.
776 .SS trailingData
777 .IX Subsection "trailingData"
778 Usage is
779 .PP
780 .Vb 1
781 \& my $data = $z\->trailingData();
782 .Ve
783 .PP
784 Returns the data, if any, that is present immediately after the compressed
785 data stream once uncompression is complete. It only makes sense to call
786 this method once the end of the compressed data stream has been
787 encountered.
788 .PP
789 This option can be used when there is useful information immediately
790 following the compressed data stream, and you don't know the length of the
791 compressed data stream.
792 .PP
793 If the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from the
794 end of the compressed data stream to the end of the buffer.
795 .PP
796 If the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that is
797 left in the filehandle input buffer once the end of the compressed data
798 stream has been reached. You can then use the filehandle to read the rest
799 of the input file.
800 .PP
801 Don't bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename.
802 .PP
803 If you know the length of the compressed data stream before you start
804 uncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the
805 \&\f(CW\*(C`InputLength\*(C'\fR option in the constructor.
806 .SH Importing
807 .IX Header "Importing"
808 No symbolic constants are required by IO::Uncompress::Inflate at present.
809 .IP :all 5
810 .IX Item ":all"
811 Imports \f(CW\*(C`inflate\*(C'\fR and \f(CW$InflateError\fR.
812 Same as doing this
813 .Sp
814 .Vb 1
815 \& use IO::Uncompress::Inflate qw(inflate $InflateError) ;
816 .Ve
817 .SH EXAMPLES
818 .IX Header "EXAMPLES"
819 .SS "Working with Net::FTP"
820 .IX Subsection "Working with Net::FTP"
821 See IO::Compress::FAQ
822 .SH SUPPORT
823 .IX Header "SUPPORT"
824 General feedback/questions/bug reports should be sent to
825 <https://github.com/pmqs/IO\-Compress/issues> (preferred) or
826 <https://rt.cpan.org/Public/Dist/Display.html?Name=IO\-Compress>.
827 .SH "SEE ALSO"
828 .IX Header "SEE ALSO"
829 Compress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip, IO::Compress::Deflate, IO::Compress::RawDeflate, IO::Uncompress::RawInflate, 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
830 .PP
831 IO::Compress::FAQ
832 .PP
833 File::GlobMapper, Archive::Zip,
834 Archive::Tar,
835 IO::Zlib
836 .PP
837 For RFC 1950, 1951 and 1952 see
838 <https://datatracker.ietf.org/doc/html/rfc1950>,
839 <https://datatracker.ietf.org/doc/html/rfc1951> and
840 <https://datatracker.ietf.org/doc/html/rfc1952>
841 .PP
842 The \fIzlib\fR compression library was written by Jean-loup Gailly
843 \&\f(CW\*(C`[email protected]\*(C'\fR and Mark Adler \f(CW\*(C`[email protected]\*(C'\fR.
844 .PP
845 The primary site for the \fIzlib\fR compression library is
846 <http://www.zlib.org>.
847 .PP
848 The primary site for the \fIzlib-ng\fR compression library is
849 <https://github.com/zlib\-ng/zlib\-ng>.
850 .PP
851 The primary site for gzip is <http://www.gzip.org>.
852 .SH AUTHOR
853 .IX Header "AUTHOR"
854 This module was written by Paul Marquess, \f(CW\*(C`[email protected]\*(C'\fR.
855 .SH "MODIFICATION HISTORY"
856 .IX Header "MODIFICATION HISTORY"
857 See the Changes file.
858 .SH "COPYRIGHT AND LICENSE"
859 .IX Header "COPYRIGHT AND LICENSE"
860 Copyright (c) 2005\-2024 Paul Marquess. All rights reserved.
861 .PP
862 This program is free software; you can redistribute it and/or
863 modify it under the same terms as Perl itself.