blib/lib/File/RsyncP/Digest.pm

filter: Statementstmt 48.5% 17 / 35 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 4 totaltotal 37.0% 20 / 54 SCAR 23.5
CC
5
Cov
40%
addfile
20.0
hash
6.0
hexdigest
2.0
CRAP 10.5
« blib/lib/File/RsyncP/FileIO.pm ↑ Summary blib/lib/File/RsyncP/FileList.pm »
1 #============================================================= -*-perl-*-
2 #
3 # File::RsyncP::Digest package
4 #
5 # DESCRIPTION
6 # File::RsyncP::Digest is a perl module that implements the
7 # various message digests that rsync uses.
8 #
9 # AUTHOR
10 # Craig Barratt <cbarratt@users.sourceforge.net>
11 #
12 # COPYRIGHT
13 # File::RsyncP is Copyright (C) 2002-2015 Craig Barratt.
14 #
15 # Rsync is Copyright (C) 1996-2001 by Andrew Tridgell, 1996 by Paul
16 # Mackerras, 2001-2002 by Martin Pool, and 2003-2009 by Wayne Davison,
17 # and others.
18 #
19 # This program is free software: you can redistribute it and/or modify
20 # it under the terms of the GNU General Public License as published by
21 # the Free Software Foundation, either version 3 of the License, or
22 # (at your option) any later version.
23 #
24 # This program is distributed in the hope that it will be useful,
25 # but WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 # GNU General Public License for more details.
28 #
29 # You should have received a copy of the GNU General Public License
30 # along with this program. If not, see <http://www.gnu.org/licenses/>.
31 #
32 #========================================================================
33 #
34 # Version 0.74, released 17 Jan 2015.
35 #
36 # See http://perlrsync.sourceforge.net.
37 #
38 #========================================================================
39  
40 package File::RsyncP::Digest;
41  
42 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶use vars qw($VERSION @ISA @EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 1 require Exporter;
46 1 require DynaLoader;
47 1 require AutoLoader;
48  
49 1 @ISA = qw(Exporter AutoLoader DynaLoader);
50 # Items to export into callers namespace by default. Note: do not export
51 # names by default without a very good reason. Use EXPORT_OK instead.
52 # Do not simply export all your public functions/methods/constants.
53 1 @EXPORT = qw(
54
55 );
56 1 $VERSION = '0.74';
57  
58 1 bootstrap File::RsyncP::Digest $VERSION;
59  
60 # Preloaded methods go here.
61  
62 sub addfile
63 {
64 1 ▶ no strict 'refs'; # Countermand any strct refs in force so that we
Subroutine BEGIN: called CC=1 SCAR=0.0
65 # can still handle file-handle names.
66  
67 0 ▶ my ($self, $handle) = @_;
Subroutine addfile: not called CC=4 SCAR=30.0
Pod undocumented
68 0 my ($package, $file, $line) = caller;
69 0 my ($data) = '';
70  
71 0 ▶ if (!ref($handle))
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $handle) 0 0 0
72 {
73 # Old-style passing of filehandle by name. We need to add
74 # the calling package scope qualifier, if there is not one
75 # supplied already.
76  
77 0 ▶ $handle = $package . '::' . $handle unless ($handle =~ /(\:\:|\')/);
Branch: 1 branch
BranchTrueFalseTotal
unless $handle =~ /(\:\:|\')/ 0 0 0
78 }
79  
80 0 ▶ while (read($handle, $data, 1024))
Branch: 1 branch
BranchTrueFalseTotal
if (read $handle, $data, 1024) 0 0 0
81 {
82 0 $self->add($data);
83 }
84 0 return $self;
85 }
86  
87 sub hexdigest
88 {
89 0 ▶ my ($self) = shift;
Subroutine hexdigest: not called CC=1 SCAR=6.9
Pod undocumented
90  
91 0 unpack("H*", ($self->digest()));
92 }
93  
94 sub hash
95 {
96 0 ▶ my ($self, $data) = @_;
Subroutine hash: not called CC=2 SCAR=17.9
Pod undocumented
97  
98 0 ▶ if (ref($self))
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
99 {
100 # This is an instance method call so reset the current context
101  
102 0 $self->reset();
103 }
104 else
105 {
106 # This is a static method invocation, create a temporary MD4 context
107  
108 0 $self = new File::RsyncP::Digest;
109 }
110  
111 # Now do the hash
112  
113 0 $self->add($data);
114 0 $self->digest();
115 }
116  
117 sub hexhash
118 {
119 0 ▶ my ($self, $data) = @_;
Subroutine hexhash: not called CC=1 SCAR=6.9
Pod undocumented
120  
121 0 unpack("H*", ($self->hash($data)));
122 }
123  
124 # Autoload methods go after =cut, and are processed by the autosplit program.
125  
126 1 1;
127 __END__
« blib/lib/File/RsyncP/FileIO.pm ↑ Summary blib/lib/File/RsyncP/FileList.pm »