| 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
MC/DC0%0/1
$len ||= 64
$len
Truth table0%0/2
A
A= $len
| |||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sysopen my $fh, $file, 0 or warn $!; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | return unless defined $fh; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 0 | sysread $fh, $buff, $len; | |||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | close $fh or warn qq(Couldn't close filehandle to $file $!); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/1
$len ||= 32
$len
Truth table0%0/2
A
A= $len
| |||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 0 | my $pos = int $size / 2; | |||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sysopen my $fh, $file, 0 or warn $!; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | return unless defined $fh; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/1
$len ||= 32
$len
Truth table0%0/2
A
A= $len
| |||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | 0 | my $pos = int $size / 2; | |||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sysopen my $fh, $file, 0 or warn $!; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | return unless defined $fh; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 0 | sysread $fh, $buff_first, $len; | |||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | close $fh and return $buff_first if $size <= $len; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$size <= $len && (close $fh && (return $buff_first))
close $fh and return $buff_first
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
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/1
$len ||= 64
$len
Truth table0%0/2
A
A= $len
| |||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sysopen my $fh, $file, 0 or warn $!; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | return unless defined $fh; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return unless defined $fh; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/1
$len ||= 32
$len
Truth table0%0/2
A
A= $len
| |||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | return if $size <= $len; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $pos ||= int $size / 3; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$pos ||= int $size / 3
MC/DC0%0/2
$pos ||= int $size / 3
$pos
int $size / 3
Truth table0%0/3
A ||= B
A= $posB= int $size / 3
| |||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sysopen my $fh, $file, 0 or warn $!; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | return unless defined $fh; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | 0 | return $buff; | |||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||
| 165 | 2 | 1; | |||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | __END__ | ||||||||||||||||||||||||||||||||