Debian lenny version packages
[pkg-perl] / deb-src / libarchive-zip-perl / libarchive-zip-perl-1.18 / bin / crc32
1 #! /usr/bin/perl -w
2 # computes and prints to stdout the CRC-32 values of the given files
3 use lib qw( blib/lib lib );
4 use Archive::Zip;
5 use FileHandle;
6
7 my $totalFiles = scalar(@ARGV);
8 foreach my $file (@ARGV) {
9     if ( -d $file ) {
10         warn "$0: ${file}: Is a directory\n";
11         next;
12     }
13     my $fh = FileHandle->new();
14     if ( !$fh->open( $file, 'r' ) ) {
15         warn "$0: $!\n";
16         next;
17     }
18     binmode($fh);
19     my $buffer;
20     my $bytesRead;
21     my $crc = 0;
22     while ( $bytesRead = $fh->read( $buffer, 32768 ) ) {
23         $crc = Archive::Zip::computeCRC32( $buffer, $crc );
24     }
25     printf( "%08x", $crc );
26     print("\t$file") if ( $totalFiles > 1 );
27     print("\n");
28 }