in reply to Re: Zip file CRC validation
in thread Zip file CRC validation
# 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: $!"; binmode($fh); if ($member->extractToFileHandle($fh) != 0){ print "Error in $archivedir$filename\n"; next; } seek($fh, 0, 0); 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; } }
|
|---|