Revert Socket.t permissions to 644 after 89904c08923161afd23c629d5c2c7472a09c16bb
[p5sagit/p5-mst-13.2.git] / ext / IO-Compress / lib / IO / Uncompress / Unzip.pm
CommitLineData
a02d0f6f 1package IO::Uncompress::Unzip;
2
3require 5.004 ;
4
5# for RFC1952
6
7use strict ;
8use warnings;
9use bytes;
10
dcfdccf9 11use IO::Uncompress::RawInflate 2.020 ;
12use IO::Compress::Base::Common 2.020 qw(:Status createSelfTiedObject);
13use IO::Uncompress::Adapter::Inflate 2.020 ;
14use IO::Uncompress::Adapter::Identity 2.020 ;
15use IO::Compress::Zlib::Extra 2.020 ;
16use IO::Compress::Zip::Constants 2.020 ;
a02d0f6f 17
dcfdccf9 18use Compress::Raw::Zlib 2.020 qw(crc32) ;
c70c1701 19
2b4e0969 20BEGIN
21{
c70c1701 22 eval { require IO::Uncompress::Adapter::Bunzip2 ;
23 import IO::Uncompress::Adapter::Bunzip2 } ;
319fab50 24 #eval { require IO::Uncompress::Adapter::UnLzma ;
25 # import IO::Uncompress::Adapter::UnLzma } ;
2b4e0969 26}
27
28
a02d0f6f 29require Exporter ;
30
e7d45986 31our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $UnzipError, %headerLookup);
a02d0f6f 32
dcfdccf9 33$VERSION = '2.020';
a02d0f6f 34$UnzipError = '';
35
36@ISA = qw(Exporter IO::Uncompress::RawInflate);
37@EXPORT_OK = qw( $UnzipError unzip );
38%EXPORT_TAGS = %IO::Uncompress::RawInflate::EXPORT_TAGS ;
39push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
40Exporter::export_ok_tags('all');
41
e7d45986 42%headerLookup = (
43 ZIP_CENTRAL_HDR_SIG, \&skipCentralDirectory,
44 ZIP_END_CENTRAL_HDR_SIG, \&skipEndCentralDirectory,
45 ZIP64_END_CENTRAL_REC_HDR_SIG, \&skipCentralDirectory64Rec,
46 ZIP64_END_CENTRAL_LOC_HDR_SIG, \&skipCentralDirectory64Loc,
47 ZIP64_ARCHIVE_EXTRA_SIG, \&skipArchiveExtra,
48 ZIP64_DIGITAL_SIGNATURE_SIG, \&skipDigitalSignature,
49 );
50
a02d0f6f 51sub new
52{
53 my $class = shift ;
54 my $obj = createSelfTiedObject($class, \$UnzipError);
55 $obj->_create(undef, 0, @_);
56}
57
58sub unzip
59{
60 my $obj = createSelfTiedObject(undef, \$UnzipError);
61 return $obj->_inf(@_) ;
62}
63
64sub getExtraParams
65{
dcfdccf9 66 use IO::Compress::Base::Common 2.020 qw(:Parse);
a02d0f6f 67
68
69 return (
70# # Zip header fields
71 'Name' => [1, 1, Parse_any, undef],
72
73# 'Streaming' => [1, 1, Parse_boolean, 1],
74 );
75}
76
77sub ckParams
78{
79 my $self = shift ;
80 my $got = shift ;
81
82 # unzip always needs crc32
83 $got->value('CRC32' => 1);
84
85 *$self->{UnzipData}{Name} = $got->value('Name');
86
87 return 1;
88}
89
a1787f24 90sub mkUncomp
91{
92 my $self = shift ;
93 my $got = shift ;
94
95 my $magic = $self->ckMagic()
96 or return 0;
97
98 *$self->{Info} = $self->readHeader($magic)
99 or return undef ;
100
101 return 1;
102
103}
a02d0f6f 104
105sub ckMagic
106{
107 my $self = shift;
108
109 my $magic ;
110 $self->smartReadExact(\$magic, 4);
111
112 *$self->{HeaderPending} = $magic ;
113
114 return $self->HeaderError("Minimum header size is " .
115 4 . " bytes")
116 if length $magic != 4 ;
117
118 return $self->HeaderError("Bad Magic")
119 if ! _isZipMagic($magic) ;
120
121 *$self->{Type} = 'zip';
122
123 return $magic ;
124}
125
126
127
128sub readHeader
129{
130 my $self = shift;
131 my $magic = shift ;
132
133 my $name = *$self->{UnzipData}{Name} ;
134 my $hdr = $self->_readZipHeader($magic) ;
135
136 while (defined $hdr)
137 {
138 if (! defined $name || $hdr->{Name} eq $name)
139 {
140 return $hdr ;
141 }
142
143 # skip the data
144 my $buffer;
145 if (*$self->{ZipData}{Streaming}) {
146
147 while (1) {
148
149 my $b;
150 my $status = $self->smartRead(\$b, 1024 * 16);
151 return undef
152 if $status <= 0 ;
153
154 my $temp_buf;
155 my $out;
156 $status = *$self->{Uncomp}->uncompr(\$b, \$temp_buf, 0, $out);
157
158 return $self->saveErrorString(undef, *$self->{Uncomp}{Error},
159 *$self->{Uncomp}{ErrorNo})
160 if $self->saveStatus($status) == STATUS_ERROR;
161
162 if ($status == STATUS_ENDSTREAM) {
163 *$self->{Uncomp}->reset();
164 $self->pushBack($b) ;
165 last;
166 }
167 }
168
169 # skip the trailer
170 $self->smartReadExact(\$buffer, $hdr->{TrailerLength})
171 or return $self->saveErrorString(undef, "Truncated file");
172 }
173 else {
e7d45986 174 my $c = $hdr->{CompressedLength}->get32bit();
a02d0f6f 175 $self->smartReadExact(\$buffer, $c)
176 or return $self->saveErrorString(undef, "Truncated file");
177 $buffer = '';
178 }
179
180 $self->chkTrailer($buffer) == STATUS_OK
181 or return $self->saveErrorString(undef, "Truncated file");
182
183 $hdr = $self->_readFullZipHeader();
184
185 return $self->saveErrorString(undef, "Cannot find '$name'")
186 if $self->smartEof();
187 }
188
189 return undef;
190}
191
192sub chkTrailer
193{
194 my $self = shift;
195 my $trailer = shift;
196
197 my ($sig, $CRC32, $cSize, $uSize) ;
e7d45986 198 my ($cSizeHi, $uSizeHi) = (0, 0);
a02d0f6f 199 if (*$self->{ZipData}{Streaming}) {
e7d45986 200 $sig = unpack ("V", substr($trailer, 0, 4));
201 $CRC32 = unpack ("V", substr($trailer, 4, 4));
202
203 if (*$self->{ZipData}{Zip64} ) {
204 $cSize = U64::newUnpack_V64 substr($trailer, 8, 8);
205 $uSize = U64::newUnpack_V64 substr($trailer, 16, 8);
206 }
207 else {
208 $cSize = U64::newUnpack_V32 substr($trailer, 8, 4);
209 $uSize = U64::newUnpack_V32 substr($trailer, 12, 4);
210 }
211
a02d0f6f 212 return $self->TrailerError("Data Descriptor signature, got $sig")
c70c1701 213 if $sig != ZIP_DATA_HDR_SIG;
a02d0f6f 214 }
215 else {
216 ($CRC32, $cSize, $uSize) =
217 (*$self->{ZipData}{Crc32},
218 *$self->{ZipData}{CompressedLen},
219 *$self->{ZipData}{UnCompressedLen});
220 }
221
222 if (*$self->{Strict}) {
2b4e0969 223 return $self->TrailerError("CRC mismatch")
224 if $CRC32 != *$self->{ZipData}{CRC32} ;
a02d0f6f 225
e7d45986 226 return $self->TrailerError("CSIZE mismatch.")
227 if ! $cSize->equal(*$self->{CompSize});
a02d0f6f 228
e7d45986 229 return $self->TrailerError("USIZE mismatch.")
230 if ! $uSize->equal(*$self->{UnCompSize});
a02d0f6f 231 }
232
233 my $reachedEnd = STATUS_ERROR ;
234 # check for central directory or end of central directory
235 while (1)
236 {
237 my $magic ;
238 my $got = $self->smartRead(\$magic, 4);
239
240 return $self->saveErrorString(STATUS_ERROR, "Truncated file")
241 if $got != 4 && *$self->{Strict};
242
243 if ($got == 0) {
244 return STATUS_EOF ;
245 }
246 elsif ($got < 0) {
247 return STATUS_ERROR ;
248 }
249 elsif ($got < 4) {
250 $self->pushBack($magic) ;
251 return STATUS_OK ;
252 }
253
254 my $sig = unpack("V", $magic) ;
255
258133d1 256 my $hdr;
257 if ($hdr = $headerLookup{$sig})
a02d0f6f 258 {
258133d1 259 if (&$hdr($self, $magic) != STATUS_OK ) {
a02d0f6f 260 if (*$self->{Strict}) {
261 return STATUS_ERROR ;
262 }
263 else {
264 $self->clearError();
265 return STATUS_OK ;
266 }
267 }
e7d45986 268
269 if ($sig == ZIP_END_CENTRAL_HDR_SIG)
270 {
271 return STATUS_OK ;
272 last;
a02d0f6f 273 }
a02d0f6f 274 }
c70c1701 275 elsif ($sig == ZIP_LOCAL_HDR_SIG)
a02d0f6f 276 {
277 $self->pushBack($magic) ;
278 return STATUS_OK ;
279 }
280 else
281 {
282 # put the data back
283 $self->pushBack($magic) ;
284 last;
285 }
286 }
287
288 return $reachedEnd ;
289}
290
291sub skipCentralDirectory
292{
293 my $self = shift;
294 my $magic = shift ;
295
296 my $buffer;
297 $self->smartReadExact(\$buffer, 46 - 4)
298 or return $self->TrailerError("Minimum header size is " .
299 46 . " bytes") ;
300
301 my $keep = $magic . $buffer ;
302 *$self->{HeaderPending} = $keep ;
303
304 #my $versionMadeBy = unpack ("v", substr($buffer, 4-4, 2));
305 #my $extractVersion = unpack ("v", substr($buffer, 6-4, 2));
306 #my $gpFlag = unpack ("v", substr($buffer, 8-4, 2));
307 #my $compressedMethod = unpack ("v", substr($buffer, 10-4, 2));
308 #my $lastModTime = unpack ("V", substr($buffer, 12-4, 4));
309 #my $crc32 = unpack ("V", substr($buffer, 16-4, 4));
e7d45986 310 my $compressedLength = unpack ("V", substr($buffer, 20-4, 4));
311 my $uncompressedLength = unpack ("V", substr($buffer, 24-4, 4));
a02d0f6f 312 my $filename_length = unpack ("v", substr($buffer, 28-4, 2));
313 my $extra_length = unpack ("v", substr($buffer, 30-4, 2));
314 my $comment_length = unpack ("v", substr($buffer, 32-4, 2));
315 #my $disk_start = unpack ("v", substr($buffer, 34-4, 2));
316 #my $int_file_attrib = unpack ("v", substr($buffer, 36-4, 2));
317 #my $ext_file_attrib = unpack ("V", substr($buffer, 38-4, 2));
318 #my $lcl_hdr_offset = unpack ("V", substr($buffer, 42-4, 2));
319
320
321 my $filename;
322 my $extraField;
323 my $comment ;
324 if ($filename_length)
325 {
326 $self->smartReadExact(\$filename, $filename_length)
2b4e0969 327 or return $self->TruncatedTrailer("filename");
a02d0f6f 328 $keep .= $filename ;
329 }
330
331 if ($extra_length)
332 {
333 $self->smartReadExact(\$extraField, $extra_length)
2b4e0969 334 or return $self->TruncatedTrailer("extra");
a02d0f6f 335 $keep .= $extraField ;
336 }
337
338 if ($comment_length)
339 {
340 $self->smartReadExact(\$comment, $comment_length)
2b4e0969 341 or return $self->TruncatedTrailer("comment");
a02d0f6f 342 $keep .= $comment ;
343 }
344
345 return STATUS_OK ;
346}
347
e7d45986 348sub skipArchiveExtra
349{
350 my $self = shift;
351 my $magic = shift ;
352
353 my $buffer;
354 $self->smartReadExact(\$buffer, 4)
355 or return $self->TrailerError("Minimum header size is " .
356 4 . " bytes") ;
357
358 my $keep = $magic . $buffer ;
359
360 my $size = unpack ("V", $buffer);
361
362 $self->smartReadExact(\$buffer, $size)
363 or return $self->TrailerError("Minimum header size is " .
364 $size . " bytes") ;
365
366 $keep .= $buffer ;
367 *$self->{HeaderPending} = $keep ;
368
369 return STATUS_OK ;
370}
371
372
373sub skipCentralDirectory64Rec
374{
375 my $self = shift;
376 my $magic = shift ;
377
378 my $buffer;
379 $self->smartReadExact(\$buffer, 8)
380 or return $self->TrailerError("Minimum header size is " .
381 8 . " bytes") ;
382
383 my $keep = $magic . $buffer ;
384
385 my ($sizeLo, $sizeHi) = unpack ("V V", $buffer);
386
387 # TODO - take SizeHi into account
388 $self->smartReadExact(\$buffer, $sizeLo)
389 or return $self->TrailerError("Minimum header size is " .
390 $sizeLo . " bytes") ;
391
392 $keep .= $buffer ;
393 *$self->{HeaderPending} = $keep ;
394
395 #my $versionMadeBy = unpack ("v", substr($buffer, 0, 2));
396 #my $extractVersion = unpack ("v", substr($buffer, 2, 2));
397 #my $diskNumber = unpack ("V", substr($buffer, 4, 4));
398 #my $cntrlDirDiskNo = unpack ("V", substr($buffer, 8, 4));
399 #my $entriesInThisCD = unpack ("V V", substr($buffer, 12, 8));
400 #my $entriesInCD = unpack ("V V", substr($buffer, 20, 8));
401 #my $sizeOfCD = unpack ("V V", substr($buffer, 28, 8));
402 #my $offsetToCD = unpack ("V V", substr($buffer, 36, 8));
403
404 return STATUS_OK ;
405}
406
407sub skipCentralDirectory64Loc
408{
409 my $self = shift;
410 my $magic = shift ;
411
412 my $buffer;
413 $self->smartReadExact(\$buffer, 20 - 4)
414 or return $self->TrailerError("Minimum header size is " .
415 20 . " bytes") ;
416
417 my $keep = $magic . $buffer ;
418 *$self->{HeaderPending} = $keep ;
419
420 #my $startCdDisk = unpack ("V", substr($buffer, 4-4, 4));
421 #my $offsetToCD = unpack ("V V", substr($buffer, 8-4, 8));
422 #my $diskCount = unpack ("V", substr($buffer, 16-4, 4));
423
424 return STATUS_OK ;
425}
426
a02d0f6f 427sub skipEndCentralDirectory
428{
429 my $self = shift;
430 my $magic = shift ;
431
432 my $buffer;
433 $self->smartReadExact(\$buffer, 22 - 4)
434 or return $self->TrailerError("Minimum header size is " .
435 22 . " bytes") ;
436
437 my $keep = $magic . $buffer ;
438 *$self->{HeaderPending} = $keep ;
439
440 #my $diskNumber = unpack ("v", substr($buffer, 4-4, 2));
441 #my $cntrlDirDiskNo = unpack ("v", substr($buffer, 6-4, 2));
442 #my $entriesInThisCD = unpack ("v", substr($buffer, 8-4, 2));
443 #my $entriesInCD = unpack ("v", substr($buffer, 10-4, 2));
444 #my $sizeOfCD = unpack ("V", substr($buffer, 12-4, 2));
445 #my $offsetToCD = unpack ("V", substr($buffer, 16-4, 2));
446 my $comment_length = unpack ("v", substr($buffer, 20-4, 2));
447
448
449 my $comment ;
450 if ($comment_length)
451 {
452 $self->smartReadExact(\$comment, $comment_length)
2b4e0969 453 or return $self->TruncatedTrailer("comment");
a02d0f6f 454 $keep .= $comment ;
455 }
456
457 return STATUS_OK ;
458}
459
460
a02d0f6f 461sub _isZipMagic
462{
463 my $buffer = shift ;
464 return 0 if length $buffer < 4 ;
465 my $sig = unpack("V", $buffer) ;
c70c1701 466 return $sig == ZIP_LOCAL_HDR_SIG ;
a02d0f6f 467}
468
469
470sub _readFullZipHeader($)
471{
472 my ($self) = @_ ;
473 my $magic = '' ;
474
475 $self->smartReadExact(\$magic, 4);
476
477 *$self->{HeaderPending} = $magic ;
478
479 return $self->HeaderError("Minimum header size is " .
480 30 . " bytes")
481 if length $magic != 4 ;
482
483
484 return $self->HeaderError("Bad Magic")
485 if ! _isZipMagic($magic) ;
486
487 my $status = $self->_readZipHeader($magic);
488 delete *$self->{Transparent} if ! defined $status ;
489 return $status ;
490}
491
492sub _readZipHeader($)
493{
494 my ($self, $magic) = @_ ;
495 my ($HeaderCRC) ;
496 my ($buffer) = '' ;
497
498 $self->smartReadExact(\$buffer, 30 - 4)
499 or return $self->HeaderError("Minimum header size is " .
500 30 . " bytes") ;
501
502 my $keep = $magic . $buffer ;
503 *$self->{HeaderPending} = $keep ;
504
505 my $extractVersion = unpack ("v", substr($buffer, 4-4, 2));
506 my $gpFlag = unpack ("v", substr($buffer, 6-4, 2));
507 my $compressedMethod = unpack ("v", substr($buffer, 8-4, 2));
508 my $lastModTime = unpack ("V", substr($buffer, 10-4, 4));
509 my $crc32 = unpack ("V", substr($buffer, 14-4, 4));
e7d45986 510 my $compressedLength = new U64 unpack ("V", substr($buffer, 18-4, 4));
511 my $uncompressedLength = new U64 unpack ("V", substr($buffer, 22-4, 4));
a02d0f6f 512 my $filename_length = unpack ("v", substr($buffer, 26-4, 2));
513 my $extra_length = unpack ("v", substr($buffer, 28-4, 2));
514
515 my $filename;
516 my $extraField;
c70c1701 517 my @EXTRA = ();
518 my $streamingMode = ($gpFlag & ZIP_GP_FLAG_STREAMING_MASK) ? 1 : 0 ;
a02d0f6f 519
520 return $self->HeaderError("Streamed Stored content not supported")
521 if $streamingMode && $compressedMethod == 0 ;
522
258133d1 523 return $self->HeaderError("Encrypted content not supported")
524 if $gpFlag & (ZIP_GP_FLAG_ENCRYPTED_MASK|ZIP_GP_FLAG_STRONG_ENCRYPTED_MASK);
525
526 return $self->HeaderError("Patch content not supported")
527 if $gpFlag & ZIP_GP_FLAG_PATCHED_MASK;
528
a02d0f6f 529 *$self->{ZipData}{Streaming} = $streamingMode;
530
a02d0f6f 531
532 if ($filename_length)
533 {
534 $self->smartReadExact(\$filename, $filename_length)
c70c1701 535 or return $self->TruncatedHeader("Filename");
a02d0f6f 536 $keep .= $filename ;
537 }
538
e7d45986 539 my $zip64 = 0 ;
540
a02d0f6f 541 if ($extra_length)
542 {
543 $self->smartReadExact(\$extraField, $extra_length)
c70c1701 544 or return $self->TruncatedHeader("Extra Field");
545
546 my $bad = IO::Compress::Zlib::Extra::parseRawExtra($extraField,
547 \@EXTRA, 1, 0);
548 return $self->HeaderError($bad)
549 if defined $bad;
550
a02d0f6f 551 $keep .= $extraField ;
e7d45986 552
553 my %Extra ;
554 for (@EXTRA)
555 {
556 $Extra{$_->[0]} = \$_->[1];
557 }
558
559 if (defined $Extra{ZIP_EXTRA_ID_ZIP64()})
560 {
561 $zip64 = 1 ;
562
563 my $buff = ${ $Extra{ZIP_EXTRA_ID_ZIP64()} };
564
258133d1 565 # TODO - This code assumes that all the fields in the Zip64
566 # extra field aren't necessarily present. The spec says that
567 # they only exist if the equivalent local headers are -1.
568 # Need to check that info-zip fills out -1 in the local header
569 # correctly.
570
571 if (! $streamingMode) {
572 my $offset = 0 ;
573
574 $uncompressedLength = U64::newUnpack_V64 substr($buff, 0, 8)
575 if $uncompressedLength == 0xFFFF ;
576
577 $offset += 8 ;
578
579 $compressedLength = U64::newUnpack_V64 substr($buff, $offset, 8)
580 if $compressedLength == 0xFFFF ;
581
582 $offset += 8 ;
583
584 #my $cheaderOffset = U64::newUnpack_V64 substr($buff, 16, 8);
585 #my $diskNumber = unpack ("V", substr($buff, 24, 4));
586 }
e7d45986 587 }
588 }
589
590 *$self->{ZipData}{Zip64} = $zip64;
591
592 if (! $streamingMode) {
593 *$self->{ZipData}{Streaming} = 0;
594 *$self->{ZipData}{Crc32} = $crc32;
595 *$self->{ZipData}{CompressedLen} = $compressedLength;
596 *$self->{ZipData}{UnCompressedLen} = $uncompressedLength;
597 *$self->{CompressedInputLengthRemaining} =
598 *$self->{CompressedInputLength} = $compressedLength->get32bit();
a02d0f6f 599 }
600
2b4e0969 601 *$self->{ZipData}{Method} = $compressedMethod;
c70c1701 602 if ($compressedMethod == ZIP_CM_DEFLATE)
a02d0f6f 603 {
2b4e0969 604 *$self->{Type} = 'zip-deflate';
a1787f24 605 my $obj = IO::Uncompress::Adapter::Inflate::mkUncompObject(1,0,0);
606
607 *$self->{Uncomp} = $obj;
608 *$self->{ZipData}{CRC32} = crc32(undef);
2b4e0969 609 }
c70c1701 610 elsif ($compressedMethod == ZIP_CM_BZIP2)
2b4e0969 611 {
a1787f24 612 return $self->HeaderError("Unsupported Compression format $compressedMethod")
613 if ! defined $IO::Uncompress::Adapter::Bunzip2::VERSION ;
2b4e0969 614
615 *$self->{Type} = 'zip-bzip2';
616
a1787f24 617 my $obj = IO::Uncompress::Adapter::Bunzip2::mkUncompObject();
2b4e0969 618
619 *$self->{Uncomp} = $obj;
620 *$self->{ZipData}{CRC32} = crc32(undef);
a02d0f6f 621 }
319fab50 622# elsif ($compressedMethod == ZIP_CM_LZMA)
623# {
624# return $self->HeaderError("Unsupported Compression format $compressedMethod")
625# if ! defined $IO::Uncompress::Adapter::UnLzma::VERSION ;
626#
627# *$self->{Type} = 'zip-lzma';
628#
629# my $obj = IO::Uncompress::Adapter::UnLzma::mkUncompObject();
630#
631# *$self->{Uncomp} = $obj;
632# *$self->{ZipData}{CRC32} = crc32(undef);
633# }
c70c1701 634 elsif ($compressedMethod == ZIP_CM_STORE)
a02d0f6f 635 {
636 # TODO -- add support for reading uncompressed
637
2b4e0969 638 *$self->{Type} = 'zip-stored';
a02d0f6f 639
a1787f24 640 my $obj = IO::Uncompress::Adapter::Identity::mkUncompObject();
a02d0f6f 641
642 *$self->{Uncomp} = $obj;
a02d0f6f 643 }
644 else
645 {
646 return $self->HeaderError("Unsupported Compression format $compressedMethod");
647 }
648
649 return {
650 'Type' => 'zip',
651 'FingerprintLength' => 4,
652 #'HeaderLength' => $compressedMethod == 8 ? length $keep : 0,
653 'HeaderLength' => length $keep,
e7d45986 654 'Zip64' => $zip64,
655 'TrailerLength' => ! $streamingMode ? 0 : $zip64 ? 24 : 16,
a02d0f6f 656 'Header' => $keep,
657 'CompressedLength' => $compressedLength ,
658 'UncompressedLength' => $uncompressedLength ,
659 'CRC32' => $crc32 ,
660 'Name' => $filename,
661 'Time' => _dosToUnixTime($lastModTime),
662 'Stream' => $streamingMode,
663
664 'MethodID' => $compressedMethod,
c70c1701 665 'MethodName' => $compressedMethod == ZIP_CM_DEFLATE
a02d0f6f 666 ? "Deflated"
c70c1701 667 : $compressedMethod == ZIP_CM_BZIP2
668 ? "Bzip2"
669 : $compressedMethod == ZIP_CM_STORE
670 ? "Stored"
671 : "Unknown" ,
a02d0f6f 672
673# 'TextFlag' => $flag & GZIP_FLG_FTEXT ? 1 : 0,
674# 'HeaderCRCFlag' => $flag & GZIP_FLG_FHCRC ? 1 : 0,
675# 'NameFlag' => $flag & GZIP_FLG_FNAME ? 1 : 0,
676# 'CommentFlag' => $flag & GZIP_FLG_FCOMMENT ? 1 : 0,
677# 'ExtraFlag' => $flag & GZIP_FLG_FEXTRA ? 1 : 0,
678# 'Comment' => $comment,
679# 'OsID' => $os,
680# 'OsName' => defined $GZIP_OS_Names{$os}
681# ? $GZIP_OS_Names{$os} : "Unknown",
682# 'HeaderCRC' => $HeaderCRC,
683# 'Flags' => $flag,
684# 'ExtraFlags' => $xfl,
c70c1701 685 'ExtraFieldRaw' => $extraField,
686 'ExtraField' => [ @EXTRA ],
a02d0f6f 687
688
689 }
690}
691
2b4e0969 692sub filterUncompressed
693{
694 my $self = shift ;
695
696 if (*$self->{ZipData}{Method} == 12) {
697 *$self->{ZipData}{CRC32} = crc32(${$_[0]}, *$self->{ZipData}{CRC32});
698 }
699 else {
700 *$self->{ZipData}{CRC32} = *$self->{Uncomp}->crc32() ;
701 }
702}
703
704
dc82791d 705# from Archive::Zip & info-zip
a02d0f6f 706sub _dosToUnixTime
707{
a02d0f6f 708 my $dt = shift;
709
710 my $year = ( ( $dt >> 25 ) & 0x7f ) + 80;
711 my $mon = ( ( $dt >> 21 ) & 0x0f ) - 1;
712 my $mday = ( ( $dt >> 16 ) & 0x1f );
713
714 my $hour = ( ( $dt >> 11 ) & 0x1f );
715 my $min = ( ( $dt >> 5 ) & 0x3f );
716 my $sec = ( ( $dt << 1 ) & 0x3e );
717
dc82791d 718
719 use POSIX 'mktime';
720
721 my $time_t = mktime( $sec, $min, $hour, $mday, $mon, $year, 0, 0, -1 );
722 return 0 if ! defined $time_t;
a02d0f6f 723 return $time_t;
724}
725
726
7271;
728
729__END__
730
731
732=head1 NAME
733
cb7abd7f 734IO::Uncompress::Unzip - Read zip files/buffers
735
a02d0f6f 736=head1 SYNOPSIS
737
738 use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
739
740 my $status = unzip $input => $output [,OPTS]
741 or die "unzip failed: $UnzipError\n";
742
743 my $z = new IO::Uncompress::Unzip $input [OPTS]
744 or die "unzip failed: $UnzipError\n";
745
746 $status = $z->read($buffer)
747 $status = $z->read($buffer, $length)
748 $status = $z->read($buffer, $length, $offset)
749 $line = $z->getline()
750 $char = $z->getc()
751 $char = $z->ungetc()
752 $char = $z->opened()
753
754 $status = $z->inflateSync()
755
e7d45986 756 $data = $z->trailingData()
757 $status = $z->nextStream()
a02d0f6f 758 $data = $z->getHeaderInfo()
759 $z->tell()
760 $z->seek($position, $whence)
761 $z->binmode()
762 $z->fileno()
763 $z->eof()
764 $z->close()
765
766 $UnzipError ;
767
768 # IO::File mode
769
770 <$z>
771 read($z, $buffer);
772 read($z, $buffer, $length);
773 read($z, $buffer, $length, $offset);
774 tell($z)
775 seek($z, $position, $whence)
776 binmode($z)
777 fileno($z)
778 eof($z)
779 close($z)
780
a02d0f6f 781=head1 DESCRIPTION
782
a02d0f6f 783This module provides a Perl interface that allows the reading of
784zlib files/buffers.
785
786For writing zip files/buffers, see the companion module IO::Compress::Zip.
787
a02d0f6f 788=head1 Functional Interface
789
790A top-level function, C<unzip>, is provided to carry out
791"one-shot" uncompression between buffers and/or files. For finer
792control over the uncompression process, see the L</"OO Interface">
793section.
794
795 use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
796
797 unzip $input => $output [,OPTS]
798 or die "unzip failed: $UnzipError\n";
799
a02d0f6f 800The functional interface needs Perl5.005 or better.
801
a02d0f6f 802=head2 unzip $input => $output [, OPTS]
803
a02d0f6f 804C<unzip> expects at least two parameters, C<$input> and C<$output>.
805
806=head3 The C<$input> parameter
807
808The parameter, C<$input>, is used to define the source of
809the compressed data.
810
811It can take one of the following forms:
812
813=over 5
814
815=item A filename
816
817If the C<$input> parameter is a simple scalar, it is assumed to be a
818filename. This file will be opened for reading and the input data
819will be read from it.
820
821=item A filehandle
822
823If the C<$input> parameter is a filehandle, the input data will be
824read from it.
825The string '-' can be used as an alias for standard input.
826
827=item A scalar reference
828
829If C<$input> is a scalar reference, the input data will be read
830from C<$$input>.
831
832=item An array reference
833
834If C<$input> is an array reference, each element in the array must be a
835filename.
836
837The input data will be read from each file in turn.
838
839The complete array will be walked to ensure that it only
840contains valid filenames before any data is uncompressed.
841
a02d0f6f 842=item An Input FileGlob string
843
844If C<$input> is a string that is delimited by the characters "<" and ">"
845C<unzip> will assume that it is an I<input fileglob string>. The
846input is the list of files that match the fileglob.
847
848If the fileglob does not match any files ...
849
850See L<File::GlobMapper|File::GlobMapper> for more details.
851
a02d0f6f 852=back
853
854If the C<$input> parameter is any other type, C<undef> will be returned.
855
a02d0f6f 856=head3 The C<$output> parameter
857
858The parameter C<$output> is used to control the destination of the
859uncompressed data. This parameter can take one of these forms.
860
861=over 5
862
863=item A filename
864
865If the C<$output> parameter is a simple scalar, it is assumed to be a
866filename. This file will be opened for writing and the uncompressed
867data will be written to it.
868
869=item A filehandle
870
871If the C<$output> parameter is a filehandle, the uncompressed data
872will be written to it.
873The string '-' can be used as an alias for standard output.
874
a02d0f6f 875=item A scalar reference
876
877If C<$output> is a scalar reference, the uncompressed data will be
878stored in C<$$output>.
879
a02d0f6f 880=item An Array Reference
881
882If C<$output> is an array reference, the uncompressed data will be
883pushed onto the array.
884
885=item An Output FileGlob
886
887If C<$output> is a string that is delimited by the characters "<" and ">"
888C<unzip> will assume that it is an I<output fileglob string>. The
889output is the list of files that match the fileglob.
890
891When C<$output> is an fileglob string, C<$input> must also be a fileglob
892string. Anything else is an error.
893
894=back
895
896If the C<$output> parameter is any other type, C<undef> will be returned.
897
a02d0f6f 898=head2 Notes
899
c70c1701 900When C<$input> maps to multiple compressed files/buffers and C<$output> is
901a single file/buffer, after uncompression C<$output> will contain a
902concatenation of all the uncompressed data from each of the input
903files/buffers.
904
a02d0f6f 905=head2 Optional Parameters
906
907Unless specified below, the optional parameters for C<unzip>,
908C<OPTS>, are the same as those used with the OO interface defined in the
909L</"Constructor Options"> section below.
910
911=over 5
912
e7d45986 913=item C<< AutoClose => 0|1 >>
a02d0f6f 914
915This option applies to any input or output data streams to
916C<unzip> that are filehandles.
917
918If C<AutoClose> is specified, and the value is true, it will result in all
919input and/or output filehandles being closed once C<unzip> has
920completed.
921
922This parameter defaults to 0.
923
e7d45986 924=item C<< BinModeOut => 0|1 >>
a02d0f6f 925
926When writing to a file or filehandle, set C<binmode> before writing to the
927file.
928
929Defaults to 0.
930
e7d45986 931=item C<< Append => 0|1 >>
a02d0f6f 932
933TODO
934
e7d45986 935=item C<< MultiStream => 0|1 >>
a02d0f6f 936
e7d45986 937If the input file/buffer contains multiple compressed data streams, this
938option will uncompress the whole lot as a single data stream.
a02d0f6f 939
e7d45986 940Defaults to 0.
a02d0f6f 941
258133d1 942=item C<< TrailingData => $scalar >>
943
944Returns the data, if any, that is present immediately after the compressed
945data stream once uncompression is complete.
946
947This option can be used when there is useful information immediately
948following the compressed data stream, and you don't know the length of the
949compressed data stream.
950
951If the input is a buffer, C<trailingData> will return everything from the
952end of the compressed data stream to the end of the buffer.
953
954If the input is a filehandle, C<trailingData> will return the data that is
955left in the filehandle input buffer once the end of the compressed data
956stream has been reached. You can then use the filehandle to read the rest
957of the input file.
958
959Don't bother using C<trailingData> if the input is a filename.
960
258133d1 961If you know the length of the compressed data stream before you start
962uncompressing, you can avoid having to use C<trailingData> by setting the
963C<InputLength> option.
964
a02d0f6f 965=back
966
a02d0f6f 967=head2 Examples
968
969To read the contents of the file C<file1.txt.zip> and write the
970compressed data to the file C<file1.txt>.
971
972 use strict ;
973 use warnings ;
974 use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
975
976 my $input = "file1.txt.zip";
977 my $output = "file1.txt";
978 unzip $input => $output
979 or die "unzip failed: $UnzipError\n";
980
a02d0f6f 981To read from an existing Perl filehandle, C<$input>, and write the
982uncompressed data to a buffer, C<$buffer>.
983
984 use strict ;
985 use warnings ;
986 use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
987 use IO::File ;
988
989 my $input = new IO::File "<file1.txt.zip"
990 or die "Cannot open 'file1.txt.zip': $!\n" ;
991 my $buffer ;
992 unzip $input => \$buffer
993 or die "unzip failed: $UnzipError\n";
994
995To uncompress all files in the directory "/my/home" that match "*.txt.zip" and store the compressed data in the same directory
996
997 use strict ;
998 use warnings ;
999 use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
1000
1001 unzip '</my/home/*.txt.zip>' => '</my/home/#1.txt>'
1002 or die "unzip failed: $UnzipError\n";
1003
1004and if you want to compress each file one at a time, this will do the trick
1005
1006 use strict ;
1007 use warnings ;
1008 use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
1009
1010 for my $input ( glob "/my/home/*.txt.zip" )
1011 {
1012 my $output = $input;
1013 $output =~ s/.zip// ;
1014 unzip $input => $output
1015 or die "Error compressing '$input': $UnzipError\n";
1016 }
1017
1018=head1 OO Interface
1019
1020=head2 Constructor
1021
1022The format of the constructor for IO::Uncompress::Unzip is shown below
1023
a02d0f6f 1024 my $z = new IO::Uncompress::Unzip $input [OPTS]
1025 or die "IO::Uncompress::Unzip failed: $UnzipError\n";
1026
1027Returns an C<IO::Uncompress::Unzip> object on success and undef on failure.
1028The variable C<$UnzipError> will contain an error message on failure.
1029
1030If you are running Perl 5.005 or better the object, C<$z>, returned from
1031IO::Uncompress::Unzip can be used exactly like an L<IO::File|IO::File> filehandle.
1032This means that all normal input file operations can be carried out with
1033C<$z>. For example, to read a line from a compressed file/buffer you can
1034use either of these forms
1035
1036 $line = $z->getline();
1037 $line = <$z>;
1038
1039The mandatory parameter C<$input> is used to determine the source of the
1040compressed data. This parameter can take one of three forms.
1041
1042=over 5
1043
1044=item A filename
1045
1046If the C<$input> parameter is a scalar, it is assumed to be a filename. This
1047file will be opened for reading and the compressed data will be read from it.
1048
1049=item A filehandle
1050
1051If the C<$input> parameter is a filehandle, the compressed data will be
1052read from it.
1053The string '-' can be used as an alias for standard input.
1054
a02d0f6f 1055=item A scalar reference
1056
1057If C<$input> is a scalar reference, the compressed data will be read from
1058C<$$output>.
1059
1060=back
1061
1062=head2 Constructor Options
1063
a02d0f6f 1064The option names defined below are case insensitive and can be optionally
1065prefixed by a '-'. So all of the following are valid
1066
1067 -AutoClose
1068 -autoclose
1069 AUTOCLOSE
1070 autoclose
1071
1072OPTS is a combination of the following options:
1073
1074=over 5
1075
e7d45986 1076=item C<< AutoClose => 0|1 >>
a02d0f6f 1077
1078This option is only valid when the C<$input> parameter is a filehandle. If
1079specified, and the value is true, it will result in the file being closed once
1080either the C<close> method is called or the IO::Uncompress::Unzip object is
1081destroyed.
1082
1083This parameter defaults to 0.
1084
e7d45986 1085=item C<< MultiStream => 0|1 >>
a02d0f6f 1086
e7d45986 1087Treats the complete zip file/buffer as a single compressed data
1088stream. When reading in multi-stream mode each member of the zip
1089file/buffer will be uncompressed in turn until the end of the file/buffer
1090is encountered.
a02d0f6f 1091
1092This parameter defaults to 0.
1093
e7d45986 1094=item C<< Prime => $string >>
a02d0f6f 1095
1096This option will uncompress the contents of C<$string> before processing the
1097input file/buffer.
1098
1099This option can be useful when the compressed data is embedded in another
1100file/data structure and it is not possible to work out where the compressed
1101data begins without having to read the first few bytes. If this is the
1102case, the uncompression can be I<primed> with these bytes using this
1103option.
1104
e7d45986 1105=item C<< Transparent => 0|1 >>
a02d0f6f 1106
f6fd7794 1107If this option is set and the input file/buffer is not compressed data,
a02d0f6f 1108the module will allow reading of it anyway.
1109
f6fd7794 1110In addition, if the input file/buffer does contain compressed data and
1111there is non-compressed data immediately following it, setting this option
1112will make this module treat the whole file/bufffer as a single data stream.
1113
a02d0f6f 1114This option defaults to 1.
1115
e7d45986 1116=item C<< BlockSize => $num >>
a02d0f6f 1117
1118When reading the compressed input data, IO::Uncompress::Unzip will read it in
1119blocks of C<$num> bytes.
1120
1121This option defaults to 4096.
1122
e7d45986 1123=item C<< InputLength => $size >>
a02d0f6f 1124
1125When present this option will limit the number of compressed bytes read
1126from the input file/buffer to C<$size>. This option can be used in the
1127situation where there is useful data directly after the compressed data
1128stream and you know beforehand the exact length of the compressed data
1129stream.
1130
1131This option is mostly used when reading from a filehandle, in which case
1132the file pointer will be left pointing to the first byte directly after the
1133compressed data stream.
1134
a02d0f6f 1135This option defaults to off.
1136
e7d45986 1137=item C<< Append => 0|1 >>
a02d0f6f 1138
1139This option controls what the C<read> method does with uncompressed data.
1140
1141If set to 1, all uncompressed data will be appended to the output parameter
1142of the C<read> method.
1143
1144If set to 0, the contents of the output parameter of the C<read> method
1145will be overwritten by the uncompressed data.
1146
1147Defaults to 0.
1148
e7d45986 1149=item C<< Strict => 0|1 >>
a02d0f6f 1150
a02d0f6f 1151This option controls whether the extra checks defined below are used when
1152carrying out the decompression. When Strict is on, the extra tests are
1153carried out, when Strict is off they are not.
1154
1155The default for this option is off.
1156
a02d0f6f 1157=back
1158
1159=head2 Examples
1160
1161TODO
1162
1163=head1 Methods
1164
1165=head2 read
1166
1167Usage is
1168
1169 $status = $z->read($buffer)
1170
1171Reads a block of compressed data (the size the the compressed block is
1172determined by the C<Buffer> option in the constructor), uncompresses it and
1173writes any uncompressed data into C<$buffer>. If the C<Append> parameter is
1174set in the constructor, the uncompressed data will be appended to the
1175C<$buffer> parameter. Otherwise C<$buffer> will be overwritten.
1176
1177Returns the number of uncompressed bytes written to C<$buffer>, zero if eof
1178or a negative number on error.
1179
1180=head2 read
1181
1182Usage is
1183
1184 $status = $z->read($buffer, $length)
1185 $status = $z->read($buffer, $length, $offset)
1186
1187 $status = read($z, $buffer, $length)
1188 $status = read($z, $buffer, $length, $offset)
1189
1190Attempt to read C<$length> bytes of uncompressed data into C<$buffer>.
1191
1192The main difference between this form of the C<read> method and the
1193previous one, is that this one will attempt to return I<exactly> C<$length>
1194bytes. The only circumstances that this function will not is if end-of-file
1195or an IO error is encountered.
1196
1197Returns the number of uncompressed bytes written to C<$buffer>, zero if eof
1198or a negative number on error.
1199
a02d0f6f 1200=head2 getline
1201
1202Usage is
1203
1204 $line = $z->getline()
1205 $line = <$z>
1206
1207Reads a single line.
1208
258133d1 1209This method fully supports the use of of the variable C<$/> (or
1210C<$INPUT_RECORD_SEPARATOR> or C<$RS> when C<English> is in use) to
1211determine what constitutes an end of line. Paragraph mode, record mode and
1212file slurp mode are all supported.
a02d0f6f 1213
a02d0f6f 1214=head2 getc
1215
1216Usage is
1217
1218 $char = $z->getc()
1219
1220Read a single character.
1221
1222=head2 ungetc
1223
1224Usage is
1225
1226 $char = $z->ungetc($string)
1227
a02d0f6f 1228=head2 inflateSync
1229
1230Usage is
1231
1232 $status = $z->inflateSync()
1233
1234TODO
1235
a02d0f6f 1236=head2 getHeaderInfo
1237
1238Usage is
1239
1240 $hdr = $z->getHeaderInfo();
1241 @hdrs = $z->getHeaderInfo();
1242
1243This method returns either a hash reference (in scalar context) or a list
1244or hash references (in array context) that contains information about each
1245of the header fields in the compressed data stream(s).
1246
a02d0f6f 1247=head2 tell
1248
1249Usage is
1250
1251 $z->tell()
1252 tell $z
1253
1254Returns the uncompressed file offset.
1255
1256=head2 eof
1257
1258Usage is
1259
1260 $z->eof();
1261 eof($z);
1262
a02d0f6f 1263Returns true if the end of the compressed input stream has been reached.
1264
a02d0f6f 1265=head2 seek
1266
1267 $z->seek($position, $whence);
1268 seek($z, $position, $whence);
1269
a02d0f6f 1270Provides a sub-set of the C<seek> functionality, with the restriction
1271that it is only legal to seek forward in the input file/buffer.
1272It is a fatal error to attempt to seek backward.
1273
a02d0f6f 1274The C<$whence> parameter takes one the usual values, namely SEEK_SET,
1275SEEK_CUR or SEEK_END.
1276
1277Returns 1 on success, 0 on failure.
1278
1279=head2 binmode
1280
1281Usage is
1282
1283 $z->binmode
1284 binmode $z ;
1285
1286This is a noop provided for completeness.
1287
1288=head2 opened
1289
1290 $z->opened()
1291
1292Returns true if the object currently refers to a opened file/buffer.
1293
1294=head2 autoflush
1295
1296 my $prev = $z->autoflush()
1297 my $prev = $z->autoflush(EXPR)
1298
1299If the C<$z> object is associated with a file or a filehandle, this method
1300returns the current autoflush setting for the underlying filehandle. If
1301C<EXPR> is present, and is non-zero, it will enable flushing after every
1302write/print operation.
1303
1304If C<$z> is associated with a buffer, this method has no effect and always
1305returns C<undef>.
1306
1307B<Note> that the special variable C<$|> B<cannot> be used to set or
1308retrieve the autoflush setting.
1309
1310=head2 input_line_number
1311
1312 $z->input_line_number()
1313 $z->input_line_number(EXPR)
1314
a02d0f6f 1315Returns the current uncompressed line number. If C<EXPR> is present it has
1316the effect of setting the line number. Note that setting the line number
1317does not change the current position within the file/buffer being read.
1318
1319The contents of C<$/> are used to to determine what constitutes a line
1320terminator.
1321
a02d0f6f 1322=head2 fileno
1323
1324 $z->fileno()
1325 fileno($z)
1326
d54256af 1327If the C<$z> object is associated with a file or a filehandle, C<fileno>
1328will return the underlying file descriptor. Once the C<close> method is
1329called C<fileno> will return C<undef>.
a02d0f6f 1330
d54256af 1331If the C<$z> object is is associated with a buffer, this method will return
1332C<undef>.
a02d0f6f 1333
1334=head2 close
1335
1336 $z->close() ;
1337 close $z ;
1338
a02d0f6f 1339Closes the output file/buffer.
1340
a02d0f6f 1341For most versions of Perl this method will be automatically invoked if
1342the IO::Uncompress::Unzip object is destroyed (either explicitly or by the
1343variable with the reference to the object going out of scope). The
1344exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
1345these cases, the C<close> method will be called automatically, but
1346not until global destruction of all live objects when the program is
1347terminating.
1348
1349Therefore, if you want your scripts to be able to run on all versions
1350of Perl, you should call C<close> explicitly and not rely on automatic
1351closing.
1352
1353Returns true on success, otherwise 0.
1354
1355If the C<AutoClose> option has been enabled when the IO::Uncompress::Unzip
1356object was created, and the object is associated with a file, the
1357underlying file will also be closed.
1358
e7d45986 1359=head2 nextStream
1360
1361Usage is
1362
1363 my $status = $z->nextStream();
1364
1365Skips to the next compressed data stream in the input file/buffer. If a new
258133d1 1366compressed data stream is found, the eof marker will be cleared and C<$.>
1367will be reset to 0.
e7d45986 1368
1369Returns 1 if a new stream was found, 0 if none was found, and -1 if an
1370error was encountered.
1371
1372=head2 trailingData
1373
1374Usage is
1375
1376 my $data = $z->trailingData();
1377
258133d1 1378Returns the data, if any, that is present immediately after the compressed
1379data stream once uncompression is complete. It only makes sense to call
1380this method once the end of the compressed data stream has been
1381encountered.
1382
1383This option can be used when there is useful information immediately
1384following the compressed data stream, and you don't know the length of the
1385compressed data stream.
1386
1387If the input is a buffer, C<trailingData> will return everything from the
1388end of the compressed data stream to the end of the buffer.
1389
1390If the input is a filehandle, C<trailingData> will return the data that is
1391left in the filehandle input buffer once the end of the compressed data
1392stream has been reached. You can then use the filehandle to read the rest
1393of the input file.
1394
1395Don't bother using C<trailingData> if the input is a filename.
1396
258133d1 1397If you know the length of the compressed data stream before you start
1398uncompressing, you can avoid having to use C<trailingData> by setting the
1399C<InputLength> option in the constructor.
e7d45986 1400
a02d0f6f 1401=head1 Importing
1402
1403No symbolic constants are required by this IO::Uncompress::Unzip at present.
1404
1405=over 5
1406
1407=item :all
1408
1409Imports C<unzip> and C<$UnzipError>.
1410Same as doing this
1411
1412 use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
1413
1414=back
1415
1416=head1 EXAMPLES
1417
d54256af 1418=head2 Working with Net::FTP
1419
1420See L<IO::Uncompress::Unzip::FAQ|IO::Uncompress::Unzip::FAQ/"Compressed files and Net::FTP">
1421
a02d0f6f 1422=head1 SEE ALSO
1423
258133d1 1424L<Compress::Zlib>, L<IO::Compress::Gzip>, L<IO::Uncompress::Gunzip>, L<IO::Compress::Deflate>, L<IO::Uncompress::Inflate>, L<IO::Compress::RawDeflate>, L<IO::Uncompress::RawInflate>, L<IO::Compress::Bzip2>, L<IO::Uncompress::Bunzip2>, L<IO::Compress::Lzop>, L<IO::Uncompress::UnLzop>, L<IO::Compress::Lzf>, L<IO::Uncompress::UnLzf>, L<IO::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress>
a02d0f6f 1425
1426L<Compress::Zlib::FAQ|Compress::Zlib::FAQ>
1427
1428L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,
1429L<Archive::Tar|Archive::Tar>,
1430L<IO::Zlib|IO::Zlib>
1431
a02d0f6f 1432For RFC 1950, 1951 and 1952 see
1433F<http://www.faqs.org/rfcs/rfc1950.html>,
1434F<http://www.faqs.org/rfcs/rfc1951.html> and
1435F<http://www.faqs.org/rfcs/rfc1952.html>
1436
1437The I<zlib> compression library was written by Jean-loup Gailly
1438F<gzip@prep.ai.mit.edu> and Mark Adler F<madler@alumni.caltech.edu>.
1439
1440The primary site for the I<zlib> compression library is
1441F<http://www.zlib.org>.
1442
1443The primary site for gzip is F<http://www.gzip.org>.
1444
a02d0f6f 1445=head1 AUTHOR
1446
cb7abd7f 1447This module was written by Paul Marquess, F<pmqs@cpan.org>.
a02d0f6f 1448
a02d0f6f 1449=head1 MODIFICATION HISTORY
1450
1451See the Changes file.
1452
1453=head1 COPYRIGHT AND LICENSE
a02d0f6f 1454
319fab50 1455Copyright (c) 2005-2009 Paul Marquess. All rights reserved.
a02d0f6f 1456
1457This program is free software; you can redistribute it and/or
1458modify it under the same terms as Perl itself.
1459