📄 zip.pm
字号:
The default method is ZIP_CM_DEFLATE.=item C<< Stream => 0|1 >>This option controls whether the zip file/buffer output is created instreaming mode.Note that when outputting to a file with streaming mode disabled (C<Stream>is 0), the output file must be seekable.The default is 1.=item C<< Zip64 => 0|1 >>Create a Zip64 zip file/buffer. This option should only be used if you wantto store files larger than 4 Gig.If you intend to manipulate the Zip64 zip files created with this moduleusing an external zip/unzip make sure that it supports streaming Zip64. In particular, if you are using Info-Zip you need to have zip version 3.xor better to update a Zip64 archive and unzip version 6.x to read a zip64archive. At the time of writing both are beta status.When the C<Zip64> option is enabled, the C<Stream> option I<must> beenabled as well.The default is 0.=item C<< TextFlag => 0|1 >>This parameter controls the setting of a bit in the zip central header. Itis used to signal that the data stored in the zip file/buffer is probablytext.The default is 0. =item C<< ExtraFieldLocal => $data >>=item C<< ExtraFieldCentral => $data >>These options allows additional metadata to be stored in the local andcentral headers in the zip file/buffer.An extra field consists of zero or more subfields. Each subfield consistsof a two byte header followed by the subfield data.The list of subfields can be supplied in any of the following formats ExtraFieldLocal => [$id1, $data1, $id2, $data2, ... ] ExtraFieldLocal => [ [$id1 => $data1], [$id2 => $data2], ... ] ExtraFieldLocal => { $id1 => $data1, $id2 => $data2, ... }Where C<$id1>, C<$id2> are two byte subfield ID's. If you use the hash syntax, you have no control over the order in whichthe ExtraSubFields are stored, plus you cannot have SubFields withduplicate ID.Alternatively the list of subfields can by supplied as a scalar, thus ExtraField => $rawdataThe Extended Time field, set using the C<exTime> option, is an example ofan extended field.If the C<Minimal> option is set to true, this option will be ignored.The maximum size of an extra field 65535 bytes.=item C<< Minimal => 1|0 >>If specified, this option will disable the creation of all extended fieldsin the zip local and central headers. So the C<exTime>, C<ExtraFieldLocal>and C<ExtraFieldCentral> options will be ignored.This parameter defaults to 0.=item C<< BlockSize100K => number >>Specify the number of 100K blocks bzip2 uses during compression. Valid values are from 1 to 9, where 9 is best compression.This option is only valid if the C<Method> is ZIP_CM_BZIP2. It is ignoredotherwise.The default is 1.=item C<< WorkFactor => number >>Specifies how much effort bzip2 should take before resorting to a slowerfallback compression algorithm.Valid values range from 0 to 250, where 0 means use the default value 30.This option is only valid if the C<Method> is ZIP_CM_BZIP2. It is ignoredotherwise.The default is 0.=item -Level Defines the compression level used by zlib. The value should either bea number between 0 and 9 (0 means no compression and 9 is maximumcompression), or one of the symbolic constants defined below. Z_NO_COMPRESSION Z_BEST_SPEED Z_BEST_COMPRESSION Z_DEFAULT_COMPRESSIONThe default is Z_DEFAULT_COMPRESSION.Note, these constants are not imported by C<IO::Compress::Zip> by default. use IO::Compress::Zip qw(:strategy); use IO::Compress::Zip qw(:constants); use IO::Compress::Zip qw(:all);=item -Strategy Defines the strategy used to tune the compression. Use one of the symbolicconstants defined below. Z_FILTERED Z_HUFFMAN_ONLY Z_RLE Z_FIXED Z_DEFAULT_STRATEGYThe default is Z_DEFAULT_STRATEGY.=item C<< Strict => 0|1 >>This is a placeholder option.=back=head2 ExamplesTODO=head1 Methods =head2 printUsage is $z->print($data) print $z $dataCompresses and outputs the contents of the C<$data> parameter. Thishas the same behaviour as the C<print> built-in.Returns true if successful.=head2 printfUsage is $z->printf($format, $data) printf $z $format, $dataCompresses and outputs the contents of the C<$data> parameter.Returns true if successful.=head2 syswriteUsage is $z->syswrite $data $z->syswrite $data, $length $z->syswrite $data, $length, $offsetCompresses and outputs the contents of the C<$data> parameter.Returns the number of uncompressed bytes written, or C<undef> ifunsuccessful.=head2 writeUsage is $z->write $data $z->write $data, $length $z->write $data, $length, $offsetCompresses and outputs the contents of the C<$data> parameter.Returns the number of uncompressed bytes written, or C<undef> ifunsuccessful.=head2 flushUsage is $z->flush; $z->flush($flush_type);Flushes any pending compressed data to the output file/buffer.This method takes an optional parameter, C<$flush_type>, that controlshow the flushing will be carried out. By default the C<$flush_type>used is C<Z_FINISH>. Other valid values for C<$flush_type> areC<Z_NO_FLUSH>, C<Z_SYNC_FLUSH>, C<Z_FULL_FLUSH> and C<Z_BLOCK>. It isstrongly recommended that you only set the C<flush_type> parameter ifyou fully understand the implications of what it does - overuse of C<flush>can seriously degrade the level of compression achieved. See the C<zlib>documentation for details.Returns true on success.=head2 tellUsage is $z->tell() tell $zReturns the uncompressed file offset.=head2 eofUsage is $z->eof(); eof($z);Returns true if the C<close> method has been called.=head2 seek $z->seek($position, $whence); seek($z, $position, $whence);Provides a sub-set of the C<seek> functionality, with the restrictionthat it is only legal to seek forward in the output file/buffer.It is a fatal error to attempt to seek backward.Empty parts of the file/buffer will have NULL (0x00) bytes written to them.The C<$whence> parameter takes one the usual values, namely SEEK_SET,SEEK_CUR or SEEK_END.Returns 1 on success, 0 on failure.=head2 binmodeUsage is $z->binmode binmode $z ;This is a noop provided for completeness.=head2 opened $z->opened()Returns true if the object currently refers to a opened file/buffer. =head2 autoflush my $prev = $z->autoflush() my $prev = $z->autoflush(EXPR)If the C<$z> object is associated with a file or a filehandle, this methodreturns the current autoflush setting for the underlying filehandle. IfC<EXPR> is present, and is non-zero, it will enable flushing after everywrite/print operation.If C<$z> is associated with a buffer, this method has no effect and alwaysreturns C<undef>.B<Note> that the special variable C<$|> B<cannot> be used to set orretrieve the autoflush setting.=head2 input_line_number $z->input_line_number() $z->input_line_number(EXPR)This method always returns C<undef> when compressing. =head2 fileno $z->fileno() fileno($z)If the C<$z> object is associated with a file or a filehandle, this methodwill return the underlying file descriptor.If the C<$z> object is is associated with a buffer, this method willreturn undef.=head2 close $z->close() ; close $z ;Flushes any pending compressed data and then closes the output file/buffer. For most versions of Perl this method will be automatically invoked ifthe IO::Compress::Zip object is destroyed (either explicitly or by thevariable with the reference to the object going out of scope). Theexceptions are Perl versions 5.005 through 5.00504 and 5.8.0. Inthese cases, the C<close> method will be called automatically, butnot until global destruction of all live objects when the program isterminating.Therefore, if you want your scripts to be able to run on all versionsof Perl, you should call C<close> explicitly and not rely on automaticclosing.Returns true on success, otherwise 0.If the C<AutoClose> option has been enabled when the IO::Compress::Zipobject was created, and the object is associated with a file, theunderlying file will also be closed.=head2 newStream([OPTS])Usage is $z->newStream( [OPTS] )Closes the current compressed data stream and starts a new one.OPTS consists of any of the the options that are available when creatingthe C<$z> object.See the L</"Constructor Options"> section for more details.=head2 deflateParamsUsage is $z->deflateParamsTODO=head1 Importing A number of symbolic constants are required by some methods in C<IO::Compress::Zip>. None are imported by default.=over 5=item :allImports C<zip>, C<$ZipError> and all symbolicconstants that can be used by C<IO::Compress::Zip>. Same as doing this use IO::Compress::Zip qw(zip $ZipError :constants) ;=item :constantsImport all symbolic constants. Same as doing this use IO::Compress::Zip qw(:flush :level :strategy :zip_method) ;=item :flushThese symbolic constants are used by the C<flush> method. Z_NO_FLUSH Z_PARTIAL_FLUSH Z_SYNC_FLUSH Z_FULL_FLUSH Z_FINISH Z_BLOCK=item :levelThese symbolic constants are used by the C<Level> option in the constructor. Z_NO_COMPRESSION Z_BEST_SPEED Z_BEST_COMPRESSION Z_DEFAULT_COMPRESSION=item :strategyThese symbolic constants are used by the C<Strategy> option in the constructor. Z_FILTERED Z_HUFFMAN_ONLY Z_RLE Z_FIXED Z_DEFAULT_STRATEGY=item :zip_methodThese symbolic constants are used by the C<Method> option in theconstructor. ZIP_CM_STORE ZIP_CM_DEFLATE ZIP_CM_BZIP2 =backFor =head1 EXAMPLESTODO=head1 SEE ALSOL<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>L<Compress::Zlib::FAQ|Compress::Zlib::FAQ>L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,L<Archive::Tar|Archive::Tar>,L<IO::Zlib|IO::Zlib>For RFC 1950, 1951 and 1952 see F<http://www.faqs.org/rfcs/rfc1950.html>,F<http://www.faqs.org/rfcs/rfc1951.html> andF<http://www.faqs.org/rfcs/rfc1952.html>The I<zlib> compression library was written by Jean-loup GaillyF<gzip@prep.ai.mit.edu> and Mark Adler F<madler@alumni.caltech.edu>.The primary site for the I<zlib> compression library isF<http://www.zlib.org>.The primary site for gzip is F<http://www.gzip.org>.=head1 AUTHORThis module was written by Paul Marquess, F<pmqs@cpan.org>. =head1 MODIFICATION HISTORYSee the Changes file.=head1 COPYRIGHT AND LICENSECopyright (c) 2005-2007 Paul Marquess. All rights reserved.This program is free software; you can redistribute it and/ormodify it under the same terms as Perl itself.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -