NAME

IO::Compress::Zlib::FAQ -- Frequently Asked Questions about IO::Compress::Zlib

DESCRIPTION

Common questions answered.

Compatibility with Unix compress/uncompress.

This module is not compatible with Unix compress.

If you have the uncompress program available, you can use this to read compressed files

open F, "uncompress -c $filename |";
while (<F>)
{
    ...

Alternatively, if you have the gunzip program available, you can use this to read compressed files

open F, "gunzip -c $filename |";
while (<F>)
{
    ...

and this to write compress files, if you have the compress program available

open F, "| compress -c $filename ";
print F "data";
...
close F ;

Accessing .tar.Z files

See previous FAQ item.

If the Archive::Tar module is installed and either the uncompress or gunzip programs are available, you can use one of these workarounds to read .tar.Z files.

Firstly with uncompress

use strict;
use warnings;
use Archive::Tar;

open F, "uncompress -c $filename |";
my $tar = Archive::Tar->new(*F);
...

and this with gunzip

use strict;
use warnings;
use Archive::Tar;

open F, "gunzip -c $filename |";
my $tar = Archive::Tar->new(*F);
...

Similarly, if the compress program is available, you can use this to write a .tar.Z file

use strict;
use warnings;
use Archive::Tar;
use IO::File;

my $fh = new IO::File "| compress -c >$filename";
my $tar = Archive::Tar->new();
...
$tar->write($fh);
$fh->close ;

Accessing Zip Files

This module provides limited support for reading/writing zip files using the IO::Compress::Zip and IO::Uncompress::Unzip modules.

A full interface for manipulating zip files is available with the Archive::Zip module. You can find it on CPAN at

http://www.cpan.org/modules/by-module/Archive/Archive-Zip-*.tar.gz    

What is Streaming mode in IO::Compress::Zip/Unzip?

Streaming mode is useful when you cannot seek backwards/forwards when reading or writing the zip file. For example if you are reading/writing from/to a socket.

When writing a zip file in streaming mode it means that the length

Why can't I read Stored Streamed content with IO::Uncompress::Unzip

Because

Technical note - when bit 3 of the general purpose flag in the local file header is set, the CRC32, compressed size and uncompressed size fields will all be set to zero. A trailer record that comes immediately after the compressed data contains the CRC32, compressed size and uncompressed size fields.

Basically when you are reading a streamed zip file in streaming mode, you won't knwo the length of the compressed data

The text below is from the InfoZip specification for the zip file structure where it discusses but 3 of the general purpose flag in the local header.

Info-ZIP note: This bit was introduced by PKZIP 2.04 for
DOS. In general, this feature can only be reliably used
together with compression methods that allow intrinsic
detection of the "end-of-compressed-data" condition. From
the set of compression methods described in this Zip archive
specification, only "deflate" and "bzip2" fulfill this
requirement.
Especially, the method STORED does not work!
The Info-ZIP tools recognize this bit regardless of the
compression method; but, they rely on correctly set
"compressed size" information in the central directory entry.

What is the difference between IO::Compress::Zip/Unzip and Archive::Zip

A::Z - full interface. an archiver.

IO::Z, as its name suggests, is reading/writing of zip files/buffers as if they were ordinary files. In addition, one of the things that IO::Z does that A::Z doesn't do at the moment is access zip file in streaming mode.

SEE ALSO

Compress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip, IO::Compress::Deflate, IO::Uncompress::Inflate, IO::Compress::RawDeflate, IO::Uncompress::RawInflate, IO::Compress::Bzip2, IO::Uncompress::Bunzip2, IO::Compress::Lzop, IO::Uncompress::UnLzop, IO::Uncompress::AnyInflate, IO::Uncompress::AnyUncompress

Compress::Zlib::FAQ

File::GlobMapper, Archive::Zip, Archive::Tar, IO::Zlib

AUTHOR

This module was written by Paul Marquess, pmqs@cpan.org.

MODIFICATION HISTORY

See the Changes file.

COPYRIGHT AND LICENSE

Copyright (c) 2005-2006 Paul Marquess. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.