Cleaing up for production release
[archive-zip.git] / bin / crc32
blobaa7da02a8ad826215f78d6d342de2dd1ce1a36e2
1 #!/usr/bin/perl
3 # Computes and prints to stdout the CRC-32 values of the given files
5 use strict;
6 use lib qw( blib/lib lib );
7 use Archive::Zip;
8 use FileHandle;
10 my $totalFiles = scalar(@ARGV);
11 foreach my $file (@ARGV) {
12 if ( -d $file ) {
13 warn "$0: ${file}: Is a directory\n";
14 next;
16 my $fh = FileHandle->new();
17 if ( !$fh->open( $file, 'r' ) ) {
18 warn "$0: $!\n";
19 next;
21 binmode($fh);
22 my $buffer;
23 my $bytesRead;
24 my $crc = 0;
25 while ( $bytesRead = $fh->read( $buffer, 32768 ) ) {
26 $crc = Archive::Zip::computeCRC32( $buffer, $crc );
28 printf( "%08x", $crc );
29 print("\t$file") if ( $totalFiles > 1 );
30 print("\n");