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