Archive-Zip
view release on metacpan or search on metacpan
lib/Archive/Zip.pm view on Meta::CPAN
$crc = 0;
$crc = Archive::Zip::computeCRC32( 'abcdef', $crc );
$crc = Archive::Zip::computeCRC32( 'ghijkl', $crc );
=item Archive::Zip::setChunkSize( $number )
=item Archive::Zip::setChunkSize( { chunkSize => $number } )
Report or change chunk size used for reading and writing.
This can make big differences in dealing with large files.
Currently, this defaults to 32K. This also changes the chunk
size used for Compress::Raw::Zlib. You must call setChunkSize()
before reading or writing. This is not exportable, so you
must call it like:
Archive::Zip::setChunkSize( 4096 );
or as a method on a zip (though this is a global setting).
Returns old chunk size.
=item Archive::Zip::chunkSize()
Returns the current chunk size:
my $chunkSize = Archive::Zip::chunkSize();
=item Archive::Zip::setErrorHandler( \&subroutine )
=item Archive::Zip::setErrorHandler( { subroutine => \&subroutine } )
Change the subroutine called with error strings. This
defaults to \&Carp::carp, but you may want to change it to
get the error strings. This is not exportable, so you must
call it like:
Archive::Zip::setErrorHandler( \&myErrorHandler );
If myErrorHandler is undef, resets handler to default.
Returns old error handler. Note that if you call Carp::carp
or a similar routine or if you're chaining to the default
error handler from your error handler, you may want to
increment the number of caller levels that are skipped (do
not just set it to a number):
$Carp::CarpLevel++;
=item Archive::Zip::tempFile( [ $tmpdir ] )
=item Archive::Zip::tempFile( { tempDir => $tmpdir } )
Create a uniquely named temp file. It will be returned open
for read/write. If C<$tmpdir> is given, it is used as the
name of a directory to create the file in. If not given,
creates the file using C<File::Spec::tmpdir()>. Generally, you can
override this choice using the
$ENV{TMPDIR}
environment variable. But see the L<File::Spec|File::Spec>
documentation for your system. Note that on many systems, if you're
running in taint mode, then you must make sure that C<$ENV{TMPDIR}> is
untainted for it to be used.
Will I<NOT> create C<$tmpdir> if it does not exist (this is a change
from prior versions!). Returns file handle and name:
my ($fh, $name) = Archive::Zip::tempFile();
my ($fh, $name) = Archive::Zip::tempFile('myTempDir');
my $fh = Archive::Zip::tempFile(); # if you don't need the name
=back
=head2 Zip Archive Accessors
=over 4
=item members()
Return a copy of the members array
my @members = $zip->members();
=item numberOfMembers()
Return the number of members I have
=item memberNames()
Return a list of the (internal) file names of the zip members
=item memberNamed( $string )
=item memberNamed( { zipName => $string } )
Return ref to member whose filename equals given filename or
undef. C<$string> must be in Zip (Unix) filename format.
=item membersMatching( $regex )
=item membersMatching( { regex => $regex } )
Return array of members whose filenames match given regular
expression in list context. Returns number of matching
members in scalar context.
my @textFileMembers = $zip->membersMatching( '.*\.txt' );
# or
my $numberOfTextFiles = $zip->membersMatching( '.*\.txt' );
=item zip64()
Returns whether the previous read or write of the archive has
been done in zip64 format.
=item desiredZip64Mode()
Gets or sets which parts of the archive should be written in
zip64 format: All parts as needed (ZIP64_AS_NEEDED), the default,
force writing the zip64 end of central directory record
(ZIP64_EOCD), force writing the zip64 EOCD record and all headers
in zip64 format (ZIP64_HEADERS).
=item versionMadeBy()
lib/Archive/Zip.pm view on Meta::CPAN
=over 4
=item
For field C<versionMadeBy>, Archive::Zip uses default value 20
(45 for the zip64 EOCD record) or any previously read value. It
never changes that value when writing a header, even if it is
written in zip64 format, or when writing the zip64 EOCD record.
=item
Likewise for field C<versionNeededToExtract>, but here
Archive::Zip forces a minimum value of 45 when writing a header
in zip64 format or the zip64 EOCD record.
=item
Finally, Archive::Zip never depends on the values of these fields
in any way when reading an archive from a file or file handle.
=back
=head2 Try to avoid IO::Scalar
One of the most common ways to use Archive::Zip is to generate Zip files
in-memory. Most people use L<IO::Scalar> for this purpose.
Unfortunately, as of 1.11 this module no longer works with L<IO::Scalar>
as it incorrectly implements seeking.
Anybody using L<IO::Scalar> should consider porting to L<IO::String>,
which is smaller, lighter, and is implemented to be perfectly compatible
with regular seekable filehandles.
Support for L<IO::Scalar> most likely will B<not> be restored in the
future, as L<IO::Scalar> itself cannot change the way it is implemented
due to back-compatibility issues.
=head2 Wrong password for encrypted members
When an encrypted member is read using the wrong password, you currently
have to re-read the entire archive to try again with the correct password.
=head1 TO DO
* auto-choosing storing vs compression
* extra field hooks (see notes.txt)
* check for duplicates on addition/renaming?
* Text file extraction (line end translation)
* Reading zip files from non-seekable inputs
(Perhaps by proxying through IO::String?)
* separate unused constants into separate module
* cookbook style docs
* Handle tainted paths correctly
* Work on better compatibility with other IO:: modules
* Support encryption
* More user-friendly decryption
=head1 SUPPORT
Bugs should be reported on GitHub
L<https://github.com/redhotpenguin/perl-Archive-Zip/issues>
For other issues contact the maintainer.
=head1 AUTHOR
Currently maintained by Fred Moyer <fred@redhotpenguin.com>
Previously maintained by Adam Kennedy <adamk@cpan.org>
Previously maintained by Steve Peters E<lt>steve@fisharerojo.orgE<gt>.
File attributes code by Maurice Aubrey E<lt>maurice@lovelyfilth.comE<gt>.
Originally by Ned Konz E<lt>nedkonz@cpan.orgE<gt>.
=head1 COPYRIGHT
Some parts copyright 2006 - 2012 Adam Kennedy.
Some parts copyright 2005 Steve Peters.
Original work copyright 2000 - 2004 Ned Konz.
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 SEE ALSO
Look at L<Archive::Zip::MemberRead> which is a wrapper that allows one to
read Zip archive members as if they were files.
L<Compress::Raw::Zlib>, L<Archive::Tar>, L<Archive::Extract>
=cut
( run in 1.951 second using v1.01-cache-2.11-cpan-39bf76dae61 )