File Coverage

blib/lib/Crypt/Checksum.pm
Criterion Covered Total %
statement 27 41 65.8
branch 4 8 50.0
condition n/a
subroutine 6 19 31.5
pod 0 13 0.0
total 37 81 45.6


line stmt bran cond sub pod time code
1             package Crypt::Checksum;
2              
3 2     2   16 use strict;
  2         4  
  2         53  
4 2     2   11 use warnings;
  2         3  
  2         263  
5             our $VERSION = '0.080_001';
6              
7             require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
8             our %EXPORT_TAGS = ( all => [qw/ adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int
9             crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int /] );
10             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
11             our @EXPORT = qw();
12              
13 2     2   13 use Carp;
  2         4  
  2         160  
14             $Carp::Internal{(__PACKAGE__)}++;
15              
16             # obsolete since v0.057, only for backwards compatibility
17 2     2   830 use Crypt::Checksum::CRC32;
  2         5  
  2         90  
18 2     2   14 use Crypt::Checksum::Adler32;
  2         13  
  2         932  
19 0     0 0 0 sub adler32_data { goto \&Crypt::Checksum::Adler32::adler32_data }
20 0     0 0 0 sub adler32_data_hex { goto \&Crypt::Checksum::Adler32::adler32_data_hex }
21 0     0 0 0 sub adler32_data_int { goto \&Crypt::Checksum::Adler32::adler32_data_int }
22 0     0 0 0 sub adler32_file { goto \&Crypt::Checksum::Adler32::adler32_file }
23 0     0 0 0 sub adler32_file_hex { goto \&Crypt::Checksum::Adler32::adler32_file_hex }
24 0     0 0 0 sub adler32_file_int { goto \&Crypt::Checksum::Adler32::adler32_file_int }
25 0     0 0 0 sub crc32_data { goto \&Crypt::Checksum::CRC32::crc32_data }
26 0     0 0 0 sub crc32_data_hex { goto \&Crypt::Checksum::CRC32::crc32_data_hex }
27 0     0 0 0 sub crc32_data_int { goto \&Crypt::Checksum::CRC32::crc32_data_int }
28 0     0 0 0 sub crc32_file { goto \&Crypt::Checksum::CRC32::crc32_file }
29 0     0 0 0 sub crc32_file_hex { goto \&Crypt::Checksum::CRC32::crc32_file_hex }
30 0     0 0 0 sub crc32_file_int { goto \&Crypt::Checksum::CRC32::crc32_file_int }
31              
32             sub addfile {
33 14     14 0 38 my ($self, $file) = @_;
34              
35 14         19 my $handle;
36 14 50       43 if (ref(\$file) eq 'SCALAR') { #filename
37 14 50       585 open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
38 14         63 binmode($handle);
39             }
40             else { #handle
41 0         0 $handle = $file
42             }
43 14 50       33 croak "FATAL: invalid handle" unless defined $handle;
44              
45 14         20 my $n;
46 14         25 my $buf = "";
47 14         337 while (($n = read($handle, $buf, 32*1024))) {
48 14         198 $self->add($buf)
49             }
50 14 50       30 croak "FATAL: read failed: $!" unless defined $n;
51              
52 14         332 return $self;
53             }
54              
55 0     0     sub CLONE_SKIP { 1 } # prevent cloning
56              
57             1;
58              
59             =pod
60              
61             =head1 NAME
62              
63             Crypt::Checksum - [internal only]
64              
65             =head1 DESCRIPTION
66              
67             You are probably looking for L or L.
68              
69             =cut