msalerno has asked for the wisdom of the Perl Monks concerning the following question:
Any assistance would be greatly appreciated. Thanksuse Archive::Zip qw( :ERROR_CODES :CONSTANTS ); use File::Path 'mkpath'; use IO::File; ## # Zipfile validation ## my $zipvalidate = Archive::Zip->new(); if ( $zipvalidate->read( $archivedir.$filename ) != 0 ) { print STDERR "ERROR Opening $archivedir$filename\n"; next; } foreach my $member ($zipvalidate->members()){ my $fh = IO::File->new_tmpfile or print "Unable to make ne +w temp file: $!"; $member->extractToFileHandle($fh); if ($member->extractToFileHandle($fh) != 0){ print "Error in $archivedir$filename\n"; next; } seek($fh, 0, 0); binmode($fh); my $buffer; my $bytesRead; my $crc = 0; while ( $bytesRead = $fh->read( $buffer, 32768 ) ) { $crc = Archive::Zip::computeCRC32( $buffer, $crc ); } printf( "\nFrom CALC: %08x", $crc ); printf( "\tFrom ZIP: %08x", $member->crc32() ); print "\t"; print $member->fileName(); print "\n"; #undef $fh; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Zip file CRC validation
by graff (Chancellor) on Jul 06, 2009 at 23:24 UTC | |
by msalerno (Beadle) on Jul 07, 2009 at 03:58 UTC | |
|
Re: Zip file CRC validation
by jwkrahn (Abbot) on Jul 06, 2009 at 18:58 UTC | |
by msalerno (Beadle) on Jul 06, 2009 at 21:46 UTC |