Debian Codegraph @

upstream/opensuse-tumbleweed/man3/IO::Uncompress::Inflate.3pm

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