lib/App/dupfind/Guts/Algorithms.pm

filter: Statementstmt 21.9% 18 / 82 Branchbran 0.0% 0 / 40 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 45.4% 5 / 11 Podpod n/a totaltotal 14.3% 23 / 160 CC 28 SCAR 35.5
CC
28
Cov
13%
_get_first_middle_last_bytes
56.0
_get_bytes_n_offset_n
56.0
_get_first_bytes
30.0
CRAP 34.7
« blib/lib/App/dupfind/Guts.pm ↑ Summary lib/App/dupfind/Threaded/ThreadManagement.pm »
1 # ABSTRACT: The private weeding algorithms available for use by public interface
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package App::dupfind::Guts::Algorithms;
7 {
8 2 $App::dupfind::Guts::Algorithms::VERSION = '0.140230'; # TRIAL
9 }
10  
11 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶use File::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 requires 'opts';
17  
18  
19 sub _get_first_bytes
20 0 ▶{
Subroutine _get_first_bytes: not called CC=5 SCAR=34.0
21 0 my ( $self, $file, $len ) = @_;
22  
23 0 my $buff;
24  
25 0 ▶ $len ||= 64;
Condition0%0/2
$len ||= 64
l!l
00
MC/DC0%0/1
$len ||= 64
$len
Truth table0%0/2
A
A= $len
Aresult
11
00
26  
27 0 ▶ sysopen my $fh, $file, 0 or warn $!;
Branch: 1 branch
BranchTrueFalseTotal
sysopen my $fh, $file, 0 or warn $! 0 0 0
28  
29 0 ▶ return unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 0 0
30  
31 0 sysread $fh, $buff, $len;
32  
33 0 ▶ close $fh or warn qq(Couldn't close filehandle to $file $!);
Branch: 1 branch
BranchTrueFalseTotal
close $fh or warn "Couldn't close filehandle to $file $!" 0 0 0
34  
35 0 return $buff;
36 }
37  
38 sub _get_middle_last_bytes
39 0 ▶{
Subroutine _get_middle_last_bytes: not called CC=5 SCAR=34.0
40 0 my ( $self, $file, $len, $size ) = @_;
41  
42 0 my ( $buff_mid, $buff_last );
43  
44 0 ▶ $len ||= 32;
Condition0%0/2
$len ||= 32
l!l
00
MC/DC0%0/1
$len ||= 32
$len
Truth table0%0/2
A
A= $len
Aresult
11
00
45  
46 0 my $pos = int $size / 2;
47  
48 0 ▶ sysopen my $fh, $file, 0 or warn $!;
Branch: 1 branch
BranchTrueFalseTotal
sysopen my $fh, $file, 0 or warn $! 0 0 0
49  
50 0 ▶ return unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 0 0
51  
52 0 sysseek $fh, $pos, 0;
53  
54 0 sysread $fh, $buff_mid, 1;
55  
56 0 sysseek $fh, $size - $len, 0;
57  
58 0 sysread $fh, $buff_last, $len;
59  
60 0 ▶ close $fh or warn qq(Couldn't close filehandle to $file $!);
Branch: 1 branch
BranchTrueFalseTotal
close $fh or warn "Couldn't close filehandle to $file $!" 0 0 0
61  
62 0 return $buff_mid . $buff_last;
63 }
64  
65 sub _get_first_middle_last_bytes
66 0 ▶{
Subroutine _get_first_middle_last_bytes: not called CC=7 SCAR=40.3
67 0 my ( $self, $file, $len, $size ) = @_;
68  
69 0 my ( $buff_first, $buff_mid, $buff_last );
70  
71 0 ▶ $len ||= 32;
Condition0%0/2
$len ||= 32
l!l
00
MC/DC0%0/1
$len ||= 32
$len
Truth table0%0/2
A
A= $len
Aresult
11
00
72  
73 0 my $pos = int $size / 2;
74  
75 0 ▶ sysopen my $fh, $file, 0 or warn $!;
Branch: 1 branch
BranchTrueFalseTotal
sysopen my $fh, $file, 0 or warn $! 0 0 0
76  
77 0 ▶ return unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 0 0
78  
79 0 sysread $fh, $buff_first, $len;
80  
81 0 ▶ close $fh and return $buff_first if $size <= $len;
Branch: 1 branch
BranchTrueFalseTotal
if $size <= $len 0 0 0
Condition0%0/5
$size <= $len && (close $fh && (return $buff_first))
!ll&&!rl&&r
000
close $fh and return $buff_first
!ll
00
MC/DC0%0/2
$size <= $len && (close $fh && (return $buff_first))
$size <= $len close $fh
Truth table0%0/3
A && B
A= $size <= $lenB= close $fh
ABresult
0X0
100
111
82  
83 0 sysseek $fh, $pos, 0;
84  
85 0 sysread $fh, $buff_mid, 1;
86  
87 0 sysseek $fh, $size - $len, 0;
88  
89 0 sysread $fh, $buff_last, $len;
90  
91 0 ▶ close $fh or warn qq(Couldn't close filehandle to $file $!);
Branch: 1 branch
BranchTrueFalseTotal
close $fh or warn "Couldn't close filehandle to $file $!" 0 0 0
92  
93 0 return $buff_first . $buff_mid . $buff_last;
94 }
95  
96 sub _get_last_bytes
97 0 ▶{
Subroutine _get_last_bytes: not called CC=5 SCAR=34.0
98 0 my ( $self, $file, $len, $size ) = @_;
99  
100 0 my $buff;
101  
102 0 ▶ $len ||= 64;
Condition0%0/2
$len ||= 64
l!l
00
MC/DC0%0/1
$len ||= 64
$len
Truth table0%0/2
A
A= $len
Aresult
11
00
103  
104 0 ▶ sysopen my $fh, $file, 0 or warn $!;
Branch: 1 branch
BranchTrueFalseTotal
sysopen my $fh, $file, 0 or warn $! 0 0 0
105  
106 0 ▶ return unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 0 0
107  
108 0 sysseek $fh, $size - $len, 0;
109  
110 0 sysread $fh, $buff, $len;
111  
112 0 ▶ close $fh or warn qq(Couldn't close filehandle to $file $!);
Branch: 1 branch
BranchTrueFalseTotal
close $fh or warn "Couldn't close filehandle to $file $!" 0 0 0
113  
114 0 return $buff;
115 }
116  
117 sub _get_middle_byte
118 0 ▶{
Subroutine _get_middle_byte: not called CC=4 SCAR=30.0
119 0 my ( $self, $file, $len, $size ) = @_;
120  
121 0 my $buff;
122  
123 0 $len = 1;
124  
125 0 my $pos = int $size / 2;
126  
127 0 ▶ sysopen my $fh, $file, 0 or warn $!;
Branch: 1 branch
BranchTrueFalseTotal
sysopen my $fh, $file, 0 or warn $! 0 0 0
128  
129 0 ▶ return unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 0 0
130  
131 0 sysseek $fh, $pos, 0;
132  
133 0 sysread $fh, $buff, $len;
134  
135 0 ▶ close $fh or warn qq(Couldn't close filehandle to $file $!);
Branch: 1 branch
BranchTrueFalseTotal
close $fh or warn "Couldn't close filehandle to $file $!" 0 0 0
136  
137 0 return $buff;
138 }
139  
140 sub _get_bytes_n_offset_n
141 0 ▶{
Subroutine _get_bytes_n_offset_n: not called CC=7 SCAR=40.3
142 0 my ( $self, $file, $len, $size, $pos ) = @_;
143  
144 0 my $buff;
145  
146 0 ▶ $len ||= 32;
Condition0%0/2
$len ||= 32
l!l
00
MC/DC0%0/1
$len ||= 32
$len
Truth table0%0/2
A
A= $len
Aresult
11
00
147  
148 0 ▶ return if $size <= $len;
Branch: 1 branch
BranchTrueFalseTotal
if $size <= $len 0 0 0
149  
150 0 ▶ $pos ||= int $size / 3;
Condition0%0/3
$pos ||= int $size / 3
l!l&&r!l&&!r
000
MC/DC0%0/2
$pos ||= int $size / 3
$pos int $size / 3
Truth table0%0/3
A ||= B
A= $posB= int $size / 3
ABresult
1X1
011
000
151  
152 0 ▶ sysopen my $fh, $file, 0 or warn $!;
Branch: 1 branch
BranchTrueFalseTotal
sysopen my $fh, $file, 0 or warn $! 0 0 0
153  
154 0 ▶ return unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 0 0
155  
156 0 sysseek $fh, $pos, 0;
157  
158 0 sysread $fh, $buff, $len;
159  
160 0 ▶ close $fh or warn qq(Couldn't close filehandle to $file $!);
Branch: 1 branch
BranchTrueFalseTotal
close $fh or warn "Couldn't close filehandle to $file $!" 0 0 0
161  
162 0 return $buff;
163 }
164  
165 2 1;
166  
167 __END__
« blib/lib/App/dupfind/Guts.pm ↑ Summary lib/App/dupfind/Threaded/ThreadManagement.pm »