📄 io::uncompress::unzip.3
字号:
This means that all normal input file operations can be carried out with\&\f(CW$z\fR. For example, to read a line from a compressed file/buffer you canuse either of these forms.PP.Vb 2\& $line = $z\->getline();\& $line = <$z>;.Ve.PPThe mandatory parameter \f(CW$input\fR is used to determine the source of thecompressed data. This parameter can take one of three forms..IP "A filename" 5.IX Item "A filename"If the \f(CW$input\fR parameter is a scalar, it is assumed to be a filename. Thisfile will be opened for reading and the compressed data will be read from it..IP "A filehandle" 5.IX Item "A filehandle"If the \f(CW$input\fR parameter is a filehandle, the compressed data will beread from it.The string '\-' can be used as an alias for standard input..IP "A scalar reference" 5.IX Item "A scalar reference"If \f(CW$input\fR is a scalar reference, the compressed data will be read from\&\f(CW$$output\fR..Sh "Constructor Options".IX Subsection "Constructor Options"The option names defined below are case insensitive and can be optionallyprefixed by a '\-'. So all of the following are valid.PP.Vb 4\& \-AutoClose\& \-autoclose\& AUTOCLOSE\& autoclose.Ve.PP\&\s-1OPTS\s0 is a combination of the following options:.ie n .IP """AutoClose => 0|1""" 5.el .IP "\f(CWAutoClose => 0|1\fR" 5.IX Item "AutoClose => 0|1"This option is only valid when the \f(CW$input\fR parameter is a filehandle. Ifspecified, and the value is true, it will result in the file being closed onceeither the \f(CW\*(C`close\*(C'\fR method is called or the IO::Uncompress::Unzip object isdestroyed..SpThis parameter defaults to 0..ie n .IP """MultiStream => 0|1""" 5.el .IP "\f(CWMultiStream => 0|1\fR" 5.IX Item "MultiStream => 0|1"Treats the complete zip file/buffer as a single compressed datastream. When reading in multi-stream mode each member of the zipfile/buffer will be uncompressed in turn until the end of the file/bufferis encountered..SpThis parameter defaults to 0..ie n .IP """Prime => $string""" 5.el .IP "\f(CWPrime => $string\fR" 5.IX Item "Prime => $string"This option will uncompress the contents of \f(CW$string\fR before processing theinput file/buffer..SpThis option can be useful when the compressed data is embedded in anotherfile/data structure and it is not possible to work out where the compresseddata begins without having to read the first few bytes. If this is thecase, the uncompression can be \fIprimed\fR with these bytes using thisoption..ie n .IP """Transparent => 0|1""" 5.el .IP "\f(CWTransparent => 0|1\fR" 5.IX Item "Transparent => 0|1"If this option is set and the input file/buffer is not compressed data,the module will allow reading of it anyway..SpIn addition, if the input file/buffer does contain compressed data andthere is non-compressed data immediately following it, setting this optionwill make this module treat the whole file/bufffer as a single data stream..SpThis option defaults to 1..ie n .IP """BlockSize => $num""" 5.el .IP "\f(CWBlockSize => $num\fR" 5.IX Item "BlockSize => $num"When reading the compressed input data, IO::Uncompress::Unzip will read it inblocks of \f(CW$num\fR bytes..SpThis option defaults to 4096..ie n .IP """InputLength => $size""" 5.el .IP "\f(CWInputLength => $size\fR" 5.IX Item "InputLength => $size"When present this option will limit the number of compressed bytes readfrom the input file/buffer to \f(CW$size\fR. This option can be used in thesituation where there is useful data directly after the compressed datastream and you know beforehand the exact length of the compressed datastream..SpThis option is mostly used when reading from a filehandle, in which casethe file pointer will be left pointing to the first byte directly after thecompressed data stream..SpThis option defaults to off..ie n .IP """Append => 0|1""" 5.el .IP "\f(CWAppend => 0|1\fR" 5.IX Item "Append => 0|1"This option controls what the \f(CW\*(C`read\*(C'\fR method does with uncompressed data..SpIf set to 1, all uncompressed data will be appended to the output parameterof the \f(CW\*(C`read\*(C'\fR method..SpIf set to 0, the contents of the output parameter of the \f(CW\*(C`read\*(C'\fR methodwill be overwritten by the uncompressed data..SpDefaults to 0..ie n .IP """Strict => 0|1""" 5.el .IP "\f(CWStrict => 0|1\fR" 5.IX Item "Strict => 0|1"This option controls whether the extra checks defined below are used whencarrying out the decompression. When Strict is on, the extra tests arecarried out, when Strict is off they are not..SpThe default for this option is off..Sh "Examples".IX Subsection "Examples"\&\s-1TODO\s0.SH "Methods".IX Header "Methods".Sh "read".IX Subsection "read"Usage is.PP.Vb 1\& $status = $z\->read($buffer).Ve.PPReads a block of compressed data (the size the the compressed block isdetermined by the \f(CW\*(C`Buffer\*(C'\fR option in the constructor), uncompresses it andwrites any uncompressed data into \f(CW$buffer\fR. If the \f(CW\*(C`Append\*(C'\fR parameter isset in the constructor, the uncompressed data will be appended to the\&\f(CW$buffer\fR parameter. Otherwise \f(CW$buffer\fR will be overwritten..PPReturns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eofor a negative number on error..Sh "read".IX Subsection "read"Usage is.PP.Vb 2\& $status = $z\->read($buffer, $length)\& $status = $z\->read($buffer, $length, $offset)\&\& $status = read($z, $buffer, $length)\& $status = read($z, $buffer, $length, $offset).Ve.PPAttempt to read \f(CW$length\fR bytes of uncompressed data into \f(CW$buffer\fR..PPThe main difference between this form of the \f(CW\*(C`read\*(C'\fR method and theprevious one, is that this one will attempt to return \fIexactly\fR \f(CW$length\fRbytes. The only circumstances that this function will not is if end-of-fileor an \s-1IO\s0 error is encountered..PPReturns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eofor a negative number on error..Sh "getline".IX Subsection "getline"Usage is.PP.Vb 2\& $line = $z\->getline()\& $line = <$z>.Ve.PPReads a single line..PPThis method fully supports the use of of the variable \f(CW$/\fR (or\&\f(CW$INPUT_RECORD_SEPARATOR\fR or \f(CW$RS\fR when \f(CW\*(C`English\*(C'\fR is in use) todetermine what constitutes an end of line. Paragraph mode, record mode andfile slurp mode are all supported..Sh "getc".IX Subsection "getc"Usage is.PP.Vb 1\& $char = $z\->getc().Ve.PPRead a single character..Sh "ungetc".IX Subsection "ungetc"Usage is.PP.Vb 1\& $char = $z\->ungetc($string).Ve.Sh "inflateSync".IX Subsection "inflateSync"Usage is.PP.Vb 1\& $status = $z\->inflateSync().Ve.PP\&\s-1TODO\s0.Sh "getHeaderInfo".IX Subsection "getHeaderInfo"Usage is.PP.Vb 2\& $hdr = $z\->getHeaderInfo();\& @hdrs = $z\->getHeaderInfo();.Ve.PPThis method returns either a hash reference (in scalar context) or a listor hash references (in array context) that contains information about eachof the header fields in the compressed data stream(s)..Sh "tell".IX Subsection "tell"Usage is.PP.Vb 2\& $z\->tell()\& tell $z.Ve.PPReturns the uncompressed file offset..Sh "eof".IX Subsection "eof"Usage is.PP.Vb 2\& $z\->eof();\& eof($z);.Ve.PPReturns true if the end of the compressed input stream has been reached..Sh "seek".IX Subsection "seek".Vb 2\& $z\->seek($position, $whence);\& seek($z, $position, $whence);.Ve.PPProvides a sub-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restrictionthat it is only legal to seek forward in the input file/buffer.It is a fatal error to attempt to seek backward..PPThe \f(CW$whence\fR parameter takes one the usual values, namely \s-1SEEK_SET\s0,\&\s-1SEEK_CUR\s0 or \s-1SEEK_END\s0..PPReturns 1 on success, 0 on failure..Sh "binmode".IX Subsection "binmode"Usage is.PP.Vb 2\& $z\->binmode\& binmode $z ;.Ve.PPThis is a noop provided for completeness..Sh "opened".IX Subsection "opened".Vb 1\& $z\->opened().Ve.PPReturns true if the object currently refers to a opened file/buffer..Sh "autoflush".IX Subsection "autoflush".Vb 2\& my $prev = $z\->autoflush()\& my $prev = $z\->autoflush(EXPR).Ve.PPIf the \f(CW$z\fR object is associated with a file or a filehandle, this methodreturns the current autoflush setting for the underlying filehandle. If\&\f(CW\*(C`EXPR\*(C'\fR is present, and is non-zero, it will enable flushing after everywrite/print operation..PPIf \f(CW$z\fR is associated with a buffer, this method has no effect and alwaysreturns \f(CW\*(C`undef\*(C'\fR..PP\&\fBNote\fR that the special variable \f(CW$|\fR \fBcannot\fR be used to set orretrieve the autoflush setting..Sh "input_line_number".IX Subsection "input_line_number".Vb 2\& $z\->input_line_number()\& $z\->input_line_number(EXPR).Ve.PPReturns the current uncompressed line number. If \f(CW\*(C`EXPR\*(C'\fR is present it hasthe effect of setting the line number. Note that setting the line numberdoes not change the current position within the file/buffer being read..PPThe contents of \f(CW$/\fR are used to to determine what constitutes a lineterminator..Sh "fileno".IX Subsection "fileno".Vb 2\& $z\->fileno()\& fileno($z).Ve.PPIf the \f(CW$z\fR object is associated with a file or a filehandle, this methodwill return the underlying file descriptor..PPIf the \f(CW$z\fR object is is associated with a buffer, this method willreturn undef..Sh "close".IX Subsection "close".Vb 2\& $z\->close() ;\& close $z ;.Ve.PPCloses the output file/buffer..PPFor most versions of Perl this method will be automatically invoked ifthe IO::Uncompress::Unzip 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 \f(CW\*(C`close\*(C'\fR method will be called automatically, butnot until global destruction of all live objects when the program isterminating..PPTherefore, if you want your scripts to be able to run on all versionsof Perl, you should call \f(CW\*(C`close\*(C'\fR explicitly and not rely on automaticclosing..PPReturns true on success, otherwise 0..PPIf the \f(CW\*(C`AutoClose\*(C'\fR option has been enabled when the IO::Uncompress::Unzipobject was created, and the object is associated with a file, theunderlying file will also be closed..Sh "nextStream".IX Subsection "nextStream"Usage is.PP.Vb 1\& my $status = $z\->nextStream();.Ve.PPSkips to the next compressed data stream in the input file/buffer. If a newcompressed data stream is found, the eof marker will be cleared and \f(CW$.\fRwill be reset to 0..PPReturns 1 if a new stream was found, 0 if none was found, and \-1 if anerror was encountered..Sh "trailingData".IX Subsection "trailingData"Usage is.PP.Vb 1\& my $data = $z\->trailingData();.Ve.PPReturns the data, if any, that is present immediately after the compresseddata stream once uncompression is complete. It only makes sense to callthis method once the end of the compressed data stream has beenencountered..PPThis option can be used when there is useful information immediatelyfollowing the compressed data stream, and you don't know the length of thecompressed data stream..PPIf the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from theend of the compressed data stream to the end of the buffer..PPIf the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that isleft in the filehandle input buffer once the end of the compressed datastream has been reached. You can then use the filehandle to read the restof the input file..PPDon't bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename..PPIf you know the length of the compressed data stream before you startuncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the\&\f(CW\*(C`InputLength\*(C'\fR option in the constructor..SH "Importing".IX Header "Importing"No symbolic constants are required by this IO::Uncompress::Unzip at present..IP ":all" 5.IX Item ":all"Imports \f(CW\*(C`unzip\*(C'\fR and \f(CW$UnzipError\fR.Same as doing this.Sp.Vb 1\& use IO::Uncompress::Unzip qw(unzip $UnzipError) ;.Ve.SH "EXAMPLES".IX Header "EXAMPLES".SH "SEE ALSO".IX Header "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::Compress::Lzf, IO::Uncompress::UnLzf, IO::Uncompress::AnyInflate, IO::Uncompress::AnyUncompress.PPCompress::Zlib::FAQ.PPFile::GlobMapper, Archive::Zip,Archive::Tar,IO::Zlib.PPFor \s-1RFC\s0 1950, 1951 and 1952 see \&\fIhttp://www.faqs.org/rfcs/rfc1950.html\fR,\&\fIhttp://www.faqs.org/rfcs/rfc1951.html\fR and\&\fIhttp://www.faqs.org/rfcs/rfc1952.html\fR.PPThe \fIzlib\fR compression library was written by Jean-loup Gailly\&\fIgzip@prep.ai.mit.edu\fR and Mark Adler \fImadler@alumni.caltech.edu\fR..PPThe primary site for the \fIzlib\fR compression library is\&\fIhttp://www.zlib.org\fR..PPThe primary site for gzip is \fIhttp://www.gzip.org\fR..SH "AUTHOR".IX Header "AUTHOR"This module was written by Paul Marquess, \fIpmqs@cpan.org\fR..SH "MODIFICATION HISTORY".IX Header "MODIFICATION HISTORY"See the Changes file..SH "COPYRIGHT AND LICENSE".IX Header "COPYRIGHT AND LICENSE"Copyright (c) 2005\-2007 Paul Marquess. All rights reserved..PPThis 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 + -