⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zip.pm

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PM
📖 第 1 页 / 共 4 页
字号:
addDirectory(), and addString() zip instance methods described above,but they don't add the new members to a zip.=over 4=item Archive::Zip::Member->newFromString( $stringOrStringRef [, $fileName] )Construct a new member from the given string. Returns undefon error.    my $member = Archive::Zip::Member->newFromString( 'This is a test',                                                 'xyz.txt' );=item newFromFile( $fileName )Construct a new member from the given file. Returns undef onerror.    my $member = Archive::Zip::Member->newFromFile( 'xyz.txt' );=item newDirectoryNamed( $directoryName [, $zipname ] )Construct a new member from the given directory.C<$directoryName> must be a valid name on your file system; it doesn'thave to exist.If given, C<$zipname> will be the name of the zip member; it must be avalid Zip (Unix) name. If not given, it will be converted fromC<$directoryName>.Returns undef on error.    my $member = Archive::Zip::Member->newDirectoryNamed( 'CVS/' );=back=head2 Member Simple accessorsThese methods get (and/or set) member attribute values.=over 4=item versionMadeBy()Gets the field from the member header.=item fileAttributeFormat( [$format] )Gets or sets the field from the member header. These areC<FA_*> values.=item versionNeededToExtract()Gets the field from the member header.=item bitFlag()Gets the general purpose bit field from the member header.This is where the C<GPBF_*> bits live.=item compressionMethod()Returns the member compression method. This is the methodthat is currently being used to compress the member data.This will be COMPRESSION_STORED for added string or filemembers, or any of the C<COMPRESSION_*> values for membersfrom a zip file. However, this module can only handle memberswhose data is in COMPRESSION_STORED or COMPRESSION_DEFLATEDformat.=item desiredCompressionMethod( [$method] )Get or set the member's C<desiredCompressionMethod>. This isthe compression method that will be used when the member iswritten. Returns prior desiredCompressionMethod. OnlyCOMPRESSION_DEFLATED or COMPRESSION_STORED are validarguments. Changing to COMPRESSION_STORED will change themember desiredCompressionLevel to 0; changing toCOMPRESSION_DEFLATED will change the memberdesiredCompressionLevel to COMPRESSION_LEVEL_DEFAULT.=item desiredCompressionLevel( [$method] )Get or set the member's desiredCompressionLevel This is themethod that will be used to write. Returns priordesiredCompressionLevel. Valid arguments are 0 through 9,COMPRESSION_LEVEL_NONE, COMPRESSION_LEVEL_DEFAULT,COMPRESSION_LEVEL_BEST_COMPRESSION, andCOMPRESSION_LEVEL_FASTEST. 0 or COMPRESSION_LEVEL_NONE willchange the desiredCompressionMethod to COMPRESSION_STORED.All other arguments will change the desiredCompressionMethodto COMPRESSION_DEFLATED.=item externalFileName()Return the member's external file name, if any, or undef.=item fileName()Get or set the member's internal filename. Returns the(possibly new) filename. Names will have backslashesconverted to forward slashes, and will have multipleconsecutive slashes converted to single ones.=item lastModFileDateTime()Return the member's last modification date/time stamp inMS-DOS format.=item lastModTime()Return the member's last modification date/time stamp,converted to unix localtime format.    print "Mod Time: " . scalar( localtime( $member->lastModTime() ) );=item setLastModFileDateTimeFromUnix()Set the member's lastModFileDateTime from the given unixtime.    $member->setLastModFileDateTimeFromUnix( time() );=item internalFileAttributes()Return the internal file attributes field from the zipheader. This is only set for members read from a zip file.=item externalFileAttributes()Return member attributes as read from the ZIP file. Note thatthese are NOT UNIX!=item unixFileAttributes( [$newAttributes] )Get or set the member's file attributes using UNIX fileattributes. Returns old attributes.    my $oldAttribs = $member->unixFileAttributes( 0666 );Note that the return value has more than just the filepermissions, so you will have to mask off the lowest bits forcomparisions.=item localExtraField( [$newField] )Gets or sets the extra field that was read from the localheader. This is not set for a member from a zip file untilafter the member has been written out. The extra field mustbe in the proper format.=item cdExtraField( [$newField] )Gets or sets the extra field that was read from the centraldirectory header. The extra field must be in the properformat.=item extraFields()Return both local and CD extra fields, concatenated.=item fileComment( [$newComment] )Get or set the member's file comment.=item hasDataDescriptor()Get or set the data descriptor flag. If this is set, thelocal header will not necessarily have the correct datasizes. Instead, a small structure will be stored at the endof the member data with these values. This should betransparent in normal operation.=item crc32()Return the CRC-32 value for this member. This will not be setfor members that were constructed from strings or externalfiles until after the member has been written.=item crc32String()Return the CRC-32 value for this member as an 8 characterprintable hex string. This will not be set for members thatwere constructed from strings or external files until afterthe member has been written.=item compressedSize()Return the compressed size for this member. This will not beset for members that were constructed from strings orexternal files until after the member has been written.=item uncompressedSize()Return the uncompressed size for this member.=item isEncrypted()Return true if this member is encrypted. The Archive::Zipmodule does not currently create or extract encryptedmembers.=item isTextFile( [$flag] )Returns true if I am a text file. Also can set the status ifgiven an argument (then returns old state). Note that thismodule does not currently do anything with this flag uponextraction or storage. That is, bytes are stored in nativeformat whether or not they came from a text file.=item isBinaryFile()Returns true if I am a binary file. Also can set the statusif given an argument (then returns old state). Note that thismodule does not currently do anything with this flag uponextraction or storage. That is, bytes are stored in nativeformat whether or not they came from a text file.=item extractToFileNamed( $fileName )Extract me to a file with the given name. The file will becreated with default modes. Directories will be created asneeded.The C<$fileName> argument should be a valid file name on yourfile system.Returns AZ_OK on success.=item isDirectory()Returns true if I am a directory.=item writeLocalHeaderRelativeOffset()Returns the file offset in bytes the last time I was written.=item wasWritten()Returns true if I was successfully written. Reset at thebeginning of a write attempt.=back=head2 Low-level member data readingIt is possible to use lower-level routines to access member datastreams, rather than the extract* methods and contents(). Forinstance, here is how to print the uncompressed contents of a memberin chunks using these methods:    my ( $member, $status, $bufferRef );    $member = $zip->memberNamed( 'xyz.txt' );    $member->desiredCompressionMethod( COMPRESSION_STORED );    $status = $member->rewindData();    die "error $status" unless $status == AZ_OK;    while ( ! $member->readIsDone() )    {    ( $bufferRef, $status ) = $member->readChunk();    die "error $status"    			if $status != AZ_OK && $status != AZ_STREAM_END;    # do something with $bufferRef:    print $$bufferRef;    }    $member->endRead();=over 4=item readChunk( [$chunkSize] )This reads the next chunk of given size from the member'sdata stream and compresses or uncompresses it as necessary,returning a reference to the bytes read and a status. If sizeargument is not given, defaults to global set byArchive::Zip::setChunkSize. Status is AZ_OK on success untilthe last chunk, where it returns AZ_STREAM_END. Returns C<(\$bytes, $status)>.    my ( $outRef, $status ) = $self->readChunk();    print $$outRef if $status != AZ_OK && $status != AZ_STREAM_END;=item rewindData()Rewind data and set up for reading data streams or writingzip files. Can take options for C<inflateInit()> orC<deflateInit()>, but this isn't likely to be necessary.Subclass overrides should call this method. Returns C<AZ_OK>on success.=item endRead()Reset the read variables and free the inflater or deflater.Must be called to close files, etc. Returns AZ_OK on success.=item readIsDone()Return true if the read has run out of data or errored out.=item contents()Return the entire uncompressed member data or undef in scalarcontext. When called in array context, returns C<( $string,$status )>; status will be AZ_OK on success:    my $string = $member->contents();    # or    my ( $string, $status ) = $member->contents();    die "error $status" unless $status == AZ_OK;Can also be used to set the contents of a member (this maychange the class of the member):    $member->contents( "this is my new contents" );=item extractToFileHandle( $fh )Extract (and uncompress, if necessary) the member's contentsto the given file handle. Return AZ_OK on success.=back=head1 Archive::Zip::FileMember methodsThe Archive::Zip::FileMember class extends Archive::Zip::Member. It is thebase class for both ZipFileMember and NewFileMember classes. This class addsan C<externalFileName> and an C<fh> member to keep track of the externalfile.=over 4=item externalFileName()Return the member's external filename.=item fh()Return the member's read file handle. Automatically opens file ifnecessary.=back=head1 Archive::Zip::ZipFileMember methodsThe Archive::Zip::ZipFileMember class represents members that have been readfrom external zip files.=over 4=item diskNumberStart()Returns the disk number that the member's local header resides in.Should be 0.=item localHeaderRelativeOffset()Returns the offset into the zip file where the member's local headeris.=item dataOffset()Returns the offset from the beginning of the zip file to the member'sdata.=back=head1 REQUIRED MODULESL<Archive::Zip> requires several other modules:L<Carp>L<Compress::Zlib>L<Cwd>L<File::Basename>L<File::Copy>L<File::Find>L<File::Path>L<File::Spec>L<File::Spec>L<IO::File>L<IO::Seekable>L<Time::Local>=head1 BUGS AND CAVEATS=head2 When not to use Archive::ZipIf you are just going to be extracting zips (and/or other archives) youare recommended to look at using L<Archive::Extract> instead, as it is mucheasier to use and factors out archive-specific functionality.=head2 Try to avoid IO::ScalarOne of the most common ways to use Archive::Zip is to generate Zip filesin-memory. Most people have 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 compatiblewith regular seekable filehandles.Support for L<IO::Scalar> most likely will B<not> be restored in thefuture, as L<IO::Scalar> itself cannot change the way it is implementeddue to back-compatibility issues.=head1 TO DO* auto-choosing storing vs compression* extra field hooks (see notes.txt)* check for dups 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 compatability with other IO:: modules=head1 SUPPORTBugs should be reported via the CPAN bug trackerL<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Archive-Zip>For other issues contact the maintainer=head1 AUTHORAdam Kennedy E<lt>adamk@cpan.orgE<gt>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 COPYRIGHTCopyright 2000 - 2004 Ned Konz.Some parts copyright 2005 Steve Peters.Some parts copyright 2006 - 2007 Adam Kennedy.This program is free software; you can redistribute it and/or modifyit under the same terms as Perl itself.=head1 SEE ALSOL<Compress::Zlib>, L<Archive::Tar>, L<Archive::Extract>There is a Japanese translation of thisdocument at L<http://www.memb.jp/~deq/perl/doc-ja/Archive-Zip.html>that was done by DEQ E<lt>deq@oct.zaq.ne.jpE<gt> . Thanks! =cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -