Debian Codegraph @

upstream/opensuse-tumbleweed/man3/IO::Uncompress::RawInflate.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::RawInflate 3pm"
61 .TH IO::Uncompress::RawInflate 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::RawInflate \- Read RFC 1951 files/buffers
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 1
71 \& use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
72 \&
73 \& my $status = rawinflate $input => $output [,OPTS]
74 \& or die "rawinflate failed: $RawInflateError\en";
75 \&
76 \& my $z = IO::Uncompress::RawInflate\->new( $input [OPTS] )
77 \& or die "rawinflate failed: $RawInflateError\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 \& $RawInflateError ;
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 1951.
118 .PP
119 For writing RFC 1951 files/buffers, see the companion module IO::Compress::RawDeflate.
120 .SH "Functional Interface"
121 .IX Header "Functional Interface"
122 A top\-level function, \f(CW\*(C`rawinflate\*(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::RawInflate qw(rawinflate $RawInflateError) ;
129 \&
130 \& rawinflate $input_filename_or_reference => $output_filename_or_reference [,OPTS]
131 \& or die "rawinflate failed: $RawInflateError\en";
132 .Ve
133 .PP
134 The functional interface needs Perl5.005 or better.
135 .ie n .SS "rawinflate $input_filename_or_reference => $output_filename_or_reference [, OPTS]"
136 .el .SS "rawinflate \f(CW$input_filename_or_reference\fP => \f(CW$output_filename_or_reference\fP [, OPTS]"
137 .IX Subsection "rawinflate $input_filename_or_reference => $output_filename_or_reference [, OPTS]"
138 \&\f(CW\*(C`rawinflate\*(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`rawinflate\*(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`rawinflate\*(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`rawinflate\*(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`rawinflate\*(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`rawinflate\*(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 This option is a no\-op.
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\*(Aqt 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\*(Aqt 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.1951\*(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::RawInflate qw(rawinflate $RawInflateError) ;
331 \&
332 \& my $input = "file1.txt.1951";
333 \& my $output = "file1.txt";
334 \& rawinflate $input => $output
335 \& or die "rawinflate failed: $RawInflateError\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::RawInflate qw(rawinflate $RawInflateError) ;
345 \& use IO::File ;
346 \&
347 \& my $input = IO::File\->new( "<file1.txt.1951" )
348 \& or die "Cannot open \*(Aqfile1.txt.1951\*(Aq: $!\en" ;
349 \& my $buffer ;
350 \& rawinflate $input => \e$buffer
351 \& or die "rawinflate failed: $RawInflateError\en";
352 .Ve
353 .PP
354 To uncompress all files in the directory "/my/home" that match "*.txt.1951" and store the compressed data in the same directory
355 .PP
356 .Vb 3
357 \& use strict ;
358 \& use warnings ;
359 \& use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
360 \&
361 \& rawinflate \*(Aq</my/home/*.txt.1951>\*(Aq => \*(Aq</my/home/#1.txt>\*(Aq
362 \& or die "rawinflate failed: $RawInflateError\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::RawInflate qw(rawinflate $RawInflateError) ;
371 \&
372 \& for my $input ( glob "/my/home/*.txt.1951" )
373 \& {
374 \& my $output = $input;
375 \& $output =~ s/.1951// ;
376 \& rawinflate $input => $output
377 \& or die "Error compressing \*(Aq$input\*(Aq: $RawInflateError\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::RawInflate is shown below
385 .PP
386 .Vb 2
387 \& my $z = IO::Uncompress::RawInflate\->new( $input [OPTS] )
388 \& or die "IO::Uncompress::RawInflate failed: $RawInflateError\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::RawInflate\*(C'\fR object on success and undef on failure.
395 The variable \f(CW$RawInflateError\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::RawInflate 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.1951\*(C'\fR and write its contents to stdout.
410 .PP
411 .Vb 3
412 \& my $filename = "myfile.1951";
413 \& my $z = IO::Uncompress::RawInflate\->new($filename)
414 \& or die "IO::Uncompress::RawInflate failed: $RawInflateError\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 \*(Aq\-\*(Aq 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 \*(Aq\-\*(Aq. 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::RawInflate 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::RawInflate 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 is a no\-op.
530 .SH Methods
531 .IX Header "Methods"
532 .SS read
533 .IX Subsection "read"
534 Usage is
535 .PP
536 .Vb 1
537 \& $status = $z\->read($buffer)
538 .Ve
539 .PP
540 Reads a block of compressed data (the size of the compressed block is
541 determined by the \f(CW\*(C`Buffer\*(C'\fR option in the constructor), uncompresses it and
542 writes any uncompressed data into \f(CW$buffer\fR. If the \f(CW\*(C`Append\*(C'\fR parameter is
543 set in the constructor, the uncompressed data will be appended to the
544 \&\f(CW$buffer\fR parameter. Otherwise \f(CW$buffer\fR will be overwritten.
545 .PP
546 Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof
547 or a negative number on error.
548 .SS read
549 .IX Subsection "read"
550 Usage is
551 .PP
552 .Vb 2
553 \& $status = $z\->read($buffer, $length)
554 \& $status = $z\->read($buffer, $length, $offset)
555 \&
556 \& $status = read($z, $buffer, $length)
557 \& $status = read($z, $buffer, $length, $offset)
558 .Ve
559 .PP
560 Attempt to read \f(CW$length\fR bytes of uncompressed data into \f(CW$buffer\fR.
561 .PP
562 The main difference between this form of the \f(CW\*(C`read\*(C'\fR method and the
563 previous one, is that this one will attempt to return \fIexactly\fR \f(CW$length\fR
564 bytes. The only circumstances that this function will not is if end\-of\-file
565 or an IO error is encountered.
566 .PP
567 Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof
568 or a negative number on error.
569 .SS getline
570 .IX Subsection "getline"
571 Usage is
572 .PP
573 .Vb 2
574 \& $line = $z\->getline()
575 \& $line = <$z>
576 .Ve
577 .PP
578 Reads a single line.
579 .PP
580 This method fully supports the use of the variable \f(CW$/\fR (or
581 \&\f(CW$INPUT_RECORD_SEPARATOR\fR or \f(CW$RS\fR when \f(CW\*(C`English\*(C'\fR is in use) to
582 determine what constitutes an end of line. Paragraph mode, record mode and
583 file slurp mode are all supported.
584 .SS getc
585 .IX Subsection "getc"
586 Usage is
587 .PP
588 .Vb 1
589 \& $char = $z\->getc()
590 .Ve
591 .PP
592 Read a single character.
593 .SS ungetc
594 .IX Subsection "ungetc"
595 Usage is
596 .PP
597 .Vb 1
598 \& $char = $z\->ungetc($string)
599 .Ve
600 .SS inflateSync
601 .IX Subsection "inflateSync"
602 Usage is
603 .PP
604 .Vb 1
605 \& $status = $z\->inflateSync()
606 .Ve
607 .PP
608 TODO
609 .SS getHeaderInfo
610 .IX Subsection "getHeaderInfo"
611 Usage is
612 .PP
613 .Vb 2
614 \& $hdr = $z\->getHeaderInfo();
615 \& @hdrs = $z\->getHeaderInfo();
616 .Ve
617 .PP
618 This method returns either a hash reference (in scalar context) or a list
619 or hash references (in array context) that contains information about each
620 of the header fields in the compressed data stream(s).
621 .SS tell
622 .IX Subsection "tell"
623 Usage is
624 .PP
625 .Vb 2
626 \& $z\->tell()
627 \& tell $z
628 .Ve
629 .PP
630 Returns the uncompressed file offset.
631 .SS eof
632 .IX Subsection "eof"
633 Usage is
634 .PP
635 .Vb 2
636 \& $z\->eof();
637 \& eof($z);
638 .Ve
639 .PP
640 Returns true if the end of the compressed input stream has been reached.
641 .SS seek
642 .IX Subsection "seek"
643 .Vb 2
644 \& $z\->seek($position, $whence);
645 \& seek($z, $position, $whence);
646 .Ve
647 .PP
648 Provides a sub\-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restriction
649 that it is only legal to seek forward in the input file/buffer.
650 It is a fatal error to attempt to seek backward.
651 .PP
652 Note that the implementation of \f(CW\*(C`seek\*(C'\fR in this module does not provide
653 true random access to a compressed file/buffer. It works by uncompressing
654 data from the current offset in the file/buffer until it reaches the
655 uncompressed offset specified in the parameters to \f(CW\*(C`seek\*(C'\fR. For very small
656 files this may be acceptable behaviour. For large files it may cause an
657 unacceptable delay.
658 .PP
659 The \f(CW$whence\fR parameter takes one the usual values, namely SEEK_SET,
660 SEEK_CUR or SEEK_END.
661 .PP
662 Returns 1 on success, 0 on failure.
663 .SS binmode
664 .IX Subsection "binmode"
665 Usage is
666 .PP
667 .Vb 2
668 \& $z\->binmode
669 \& binmode $z ;
670 .Ve
671 .PP
672 This is a noop provided for completeness.
673 .SS opened
674 .IX Subsection "opened"
675 .Vb 1
676 \& $z\->opened()
677 .Ve
678 .PP
679 Returns true if the object currently refers to a opened file/buffer.
680 .SS autoflush
681 .IX Subsection "autoflush"
682 .Vb 2
683 \& my $prev = $z\->autoflush()
684 \& my $prev = $z\->autoflush(EXPR)
685 .Ve
686 .PP
687 If the \f(CW$z\fR object is associated with a file or a filehandle, this method
688 returns the current autoflush setting for the underlying filehandle. If
689 \&\f(CW\*(C`EXPR\*(C'\fR is present, and is non\-zero, it will enable flushing after every
690 write/print operation.
691 .PP
692 If \f(CW$z\fR is associated with a buffer, this method has no effect and always
693 returns \f(CW\*(C`undef\*(C'\fR.
694 .PP
695 \&\fBNote\fR that the special variable \f(CW$|\fR \fBcannot\fR be used to set or
696 retrieve the autoflush setting.
697 .SS input_line_number
698 .IX Subsection "input_line_number"
699 .Vb 2
700 \& $z\->input_line_number()
701 \& $z\->input_line_number(EXPR)
702 .Ve
703 .PP
704 Returns the current uncompressed line number. If \f(CW\*(C`EXPR\*(C'\fR is present it has
705 the effect of setting the line number. Note that setting the line number
706 does not change the current position within the file/buffer being read.
707 .PP
708 The contents of \f(CW$/\fR are used to determine what constitutes a line
709 terminator.
710 .SS fileno
711 .IX Subsection "fileno"
712 .Vb 2
713 \& $z\->fileno()
714 \& fileno($z)
715 .Ve
716 .PP
717 If the \f(CW$z\fR object is associated with a file or a filehandle, \f(CW\*(C`fileno\*(C'\fR
718 will return the underlying file descriptor. Once the \f(CW\*(C`close\*(C'\fR method is
719 called \f(CW\*(C`fileno\*(C'\fR will return \f(CW\*(C`undef\*(C'\fR.
720 .PP
721 If the \f(CW$z\fR object is associated with a buffer, this method will return
722 \&\f(CW\*(C`undef\*(C'\fR.
723 .SS close
724 .IX Subsection "close"
725 .Vb 2
726 \& $z\->close() ;
727 \& close $z ;
728 .Ve
729 .PP
730 Closes the output file/buffer.
731 .PP
732 For most versions of Perl this method will be automatically invoked if
733 the IO::Uncompress::RawInflate object is destroyed (either explicitly or by the
734 variable with the reference to the object going out of scope). The
735 exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
736 these cases, the \f(CW\*(C`close\*(C'\fR method will be called automatically, but
737 not until global destruction of all live objects when the program is
738 terminating.
739 .PP
740 Therefore, if you want your scripts to be able to run on all versions
741 of Perl, you should call \f(CW\*(C`close\*(C'\fR explicitly and not rely on automatic
742 closing.
743 .PP
744 Returns true on success, otherwise 0.
745 .PP
746 If the \f(CW\*(C`AutoClose\*(C'\fR option has been enabled when the IO::Uncompress::RawInflate
747 object was created, and the object is associated with a file, the
748 underlying file will also be closed.
749 .SS nextStream
750 .IX Subsection "nextStream"
751 Usage is
752 .PP
753 .Vb 1
754 \& my $status = $z\->nextStream();
755 .Ve
756 .PP
757 Skips to the next compressed data stream in the input file/buffer. If a new
758 compressed data stream is found, the eof marker will be cleared and \f(CW$.\fR
759 will be reset to 0.
760 .PP
761 Returns 1 if a new stream was found, 0 if none was found, and \-1 if an
762 error was encountered.
763 .SS trailingData
764 .IX Subsection "trailingData"
765 Usage is
766 .PP
767 .Vb 1
768 \& my $data = $z\->trailingData();
769 .Ve
770 .PP
771 Returns the data, if any, that is present immediately after the compressed
772 data stream once uncompression is complete. It only makes sense to call
773 this method once the end of the compressed data stream has been
774 encountered.
775 .PP
776 This option can be used when there is useful information immediately
777 following the compressed data stream, and you don\*(Aqt know the length of the
778 compressed data stream.
779 .PP
780 If the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from the
781 end of the compressed data stream to the end of the buffer.
782 .PP
783 If the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that is
784 left in the filehandle input buffer once the end of the compressed data
785 stream has been reached. You can then use the filehandle to read the rest
786 of the input file.
787 .PP
788 Don\*(Aqt bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename.
789 .PP
790 If you know the length of the compressed data stream before you start
791 uncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the
792 \&\f(CW\*(C`InputLength\*(C'\fR option in the constructor.
793 .SH Importing
794 .IX Header "Importing"
795 No symbolic constants are required by IO::Uncompress::RawInflate at present.
796 .IP :all 5
797 .IX Item ":all"
798 Imports \f(CW\*(C`rawinflate\*(C'\fR and \f(CW$RawInflateError\fR.
799 Same as doing this
800 .Sp
801 .Vb 1
802 \& use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
803 .Ve
804 .SH EXAMPLES
805 .IX Header "EXAMPLES"
806 .SS "Working with Net::FTP"
807 .IX Subsection "Working with Net::FTP"
808 See IO::Compress::FAQ
809 .SH SUPPORT
810 .IX Header "SUPPORT"
811 General feedback/questions/bug reports should be sent to
812 <https://github.com/pmqs/IO\-Compress/issues> (preferred) or
813 <https://rt.cpan.org/Public/Dist/Display.html?Name=IO\-Compress>.
814 .SH "SEE ALSO"
815 .IX Header "SEE ALSO"
816 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
817 .PP
818 IO::Compress::FAQ
819 .PP
820 File::GlobMapper, Archive::Zip,
821 Archive::Tar,
822 IO::Zlib
823 .PP
824 For RFC 1950, 1951 and 1952 see
825 <https://datatracker.ietf.org/doc/html/rfc1950>,
826 <https://datatracker.ietf.org/doc/html/rfc1951> and
827 <https://datatracker.ietf.org/doc/html/rfc1952>
828 .PP
829 The \fIzlib\fR compression library was written by Jean\-loup Gailly
830 \&\f(CW\*(C`[email protected]\*(C'\fR and Mark Adler \f(CW\*(C`[email protected]\*(C'\fR.
831 .PP
832 The primary site for the \fIzlib\fR compression library is
833 <http://www.zlib.org>.
834 .PP
835 The primary site for the \fIzlib\-ng\fR compression library is
836 <https://github.com/zlib\-ng/zlib\-ng>.
837 .PP
838 The primary site for gzip is <http://www.gzip.org>.
839 .SH AUTHOR
840 .IX Header "AUTHOR"
841 This module was written by Paul Marquess, \f(CW\*(C`[email protected]\*(C'\fR.
842 .SH "MODIFICATION HISTORY"
843 .IX Header "MODIFICATION HISTORY"
844 See the Changes file.
845 .SH "COPYRIGHT AND LICENSE"
846 .IX Header "COPYRIGHT AND LICENSE"
847 Copyright (c) 2005\-2024 Paul Marquess. All rights reserved.
848 .PP
849 This program is free software; you can redistribute it and/or
850 modify it under the same terms as Perl itself.