| 1 | package File::Checkm; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | our $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | $VERSION = sprintf "%s", q$Name: Release-v0.3.3$ =~ /Release-(v\d+\.\d+\.\d+)/; | |||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | my $checkm_version = "0.7"; # version number of checkm spec | |||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 6 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | checkm_trees make_digester list_digesters | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | our @EXPORT_FAIL = qw( | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 | push @EXPORT_OK, @EXPORT_FAIL; # add pseudo-symbols we will trap | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub export_fail { my( $class, @symbols )=@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export_fail: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my @unknowns; | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | for (@symbols) { | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | ! s/^pair=([1-9])$/$1/ and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | push(@unknowns, $_), | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | #pair_means($_); # define how many octets form a pair | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | return @unknowns; | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | our $manfilename = "manifest.txt"; | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | ▶ | use File::Find; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | #use File::Path; | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # Globals set by checkm_trees | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | my $o_fname; # whether to include file/URL name | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | my $o_aname; # whether to include algorithm name | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | my $o_alg; # lowercase algorithm name | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 6 | my $o_digest; # whether to include digest | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | 6 | my $o_size; # whether to include size | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 6 | my $o_mtime; # whether to include mtime | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | my $o_fieldscount; # how many fields we're to do | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | my $o_digester; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | my $o_verbose; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | 6 | my $o_temper; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | my $o_mani_digester; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | my $o_mani_octets = 0; # count of octets since last checkm_point | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | my $S = '|'; # separator | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 6 | my $objectcount = 0; # number of objects encountered | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 6 | my $octetcount = 0; # number of octets encountered xxx | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 6 | my $filecount = 0; # number of files encountered xxx | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | 6 | my $dircount = 0; # number of directories encountered xxx | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | 6 | my $symlinkcount = 0; # number of symlinks encountered xxx | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | 6 | my $irregcount = 0; # non file, non dir fs items to report xxx | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 6 | my $gr_opt; # global version of r_opt to communicate with find | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # "Digest print" for digest lines, which optionally (if first arg is 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # and the verbose option is set) prints to stderr and adds lines to | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # digester so that the manifest itself gets a digest. Always appends "\n". | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 37 | ▶ | sub dprint { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dprint: called CC=5 SCAR=19.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 37 | my $errtoo = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | 37 | my $output = join("", @_) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | 37 | my $ret = print $output; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 37 | ▶ | $errtoo && $o_verbose and $ret &&= print STDERR $output; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$errtoo and $o_verbose
$ret &&= print(STDERR $output)
MC/DC0%0/2
$errtoo and $o_verbose
$errtoo
$o_verbose
MC/DC0%0/2
$ret &&= print(STDERR $output)
$ret
print(STDERR $output)
Truth table33%1/3
A and B
A= $errtooB= $o_verbose
Truth table0%0/3
A &&= B
A= $retB= print(STDERR $output)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 37 | ▶ | $o_mani_digester and $o_mani_digester->add($output); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 37 | $o_mani_octets += length($output); # track number of octets | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | # xxx or should this be length(Encoding::encode_utf8($output))? | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 37 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 5 | ▶ | sub checkm_point { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkm_point: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 5 | my $manioctets = $o_mani_octets; # save what we'll report | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | ▶ | $o_mani_digester or # we're not computing a digest | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | return dprint 0, "#%checkm_point$S$S", | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | "$S$manioctets$S", checkm_time(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | my $manidigest = $o_mani_digester->hexdigest; # resets digester | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | 5 | $o_mani_octets = 0; # save and reset so dprint starts at zero | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # XXXXX what if alg for this is different from that for addfile? | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 5 | return dprint 0, "#%checkm_point$S$o_alg$S$manidigest", | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | "$S$manioctets$S", checkm_time(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 5 | ▶ | sub checkm_trees { my( $r_trees, $r_opt, $r_visit_node, $r_wrapup )=@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkm_trees: called CC=17 SCAR=32.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # xxx $r_visit_node? $r_wrapup? | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # XXXX shouldn't croak from module? what is error return? | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # Check that we can trust our arguments. | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 5 | ▶ | ref($r_trees) eq "ARRAY" or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | croak "r_trees must reference an array"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 5 | ▶ | ref($r_opt) eq "HASH" or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | croak "r_opt must reference a hash (for input/output)"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 5 | ▶ | ref( $r_visit_node ||= \&checkm_visit_node ) eq "CODE" or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$r_visit_node ||= \&File::Checkm::checkm_visit_node
MC/DC0%0/1
$r_visit_node ||= \&File::Checkm::checkm_visit_node
$r_visit_node
Truth table50%1/2
A
A= $r_visit_node
| |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | croak "r_visit_node must reference a node-visiting function"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | #ref( $r_wrapup ||= \&checkm_lstree_wrapup ) eq "CODE" or | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # croak "r_wrapup must reference a node-visiting function"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # xxx needed? | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 5 | $gr_opt = $r_opt; # make options available to find | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # Preset some globals as a small optimization to reduce | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # reference time for each file. | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | $o_aname = $r_opt->{aname}; | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | 5 | $o_fname = $r_opt->{fname}; | |||||||||||||||||||||||||||||||||||||||||||||
| 123 | 5 | $o_alg = $r_opt->{alg}; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | 5 | $o_digest = $r_opt->{digest}; | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | 5 | $o_size = $r_opt->{size}; | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | 5 | $o_mtime = $r_opt->{mtime}; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | $o_fieldscount = $r_opt->{fieldscount}; | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | 5 | $o_digester = $r_opt->{digester}; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | $o_mani_digester = $r_opt->{mani_digester}; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | 5 | $o_verbose = $r_opt->{verbose}; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | 5 | $o_temper = $r_opt->{temper}; | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | my %find_opt = ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 'wanted' => $r_visit_node, | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 5 | 'follow_fast' => (! $r_opt->{preventlinks}), | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | #$o{follow_fast} = 1 # xxx set with $opt? | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # unless defined $o{follow_fast}; | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # Set follow_fast=1 to mean follow symlinks without rigorous | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # checking (faster); it also means that (-X _) works from | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # within &visit without doing an extra stat call, where -X | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # is any file test operator and _ is the magic file handle. | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | #dprint 0, "Id Oxum\n"; # XXXXXX this is our r_startup | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | dprint 0, "#%checkm_$checkm_version"; | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | # XXX shouldn't these filenames be checkm_encoded? | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 5 | dprint 0, "#%checkm_over$S", join(" ", @$r_trees); | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 5 | my $ret = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | for my $tree (@$r_trees) { | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | 10 | ▶ | if (! -e $tree) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # xxx ? $exit_status = 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # xxx $om->elem('error', "$tree: no such file or directory"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # If follow_fast is set and the top of the tree is not an | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # actual directory name, then it appears that File::Find | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # reports absolute pathnames, which breaks the pattern | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # we're trying to create; we handle this specially by | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # calling checkm_visit_node by hand. | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 10 | ▶ | if (! -d $tree and $find_opt{follow_fast}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not -d $tree and $find_opt{"follow_fast"}
MC/DC50%1/2
not -d $tree and $find_opt{"follow_fast"}
not -d $tree
$find_opt{"follow_fast"}
Truth table66%2/3
not(A) and B
A= not -d $treeB= $find_opt{"follow_fast"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | #$pdname = $File::Find::dir; | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 7 | $File::Find::dir = '.'; # current parent directory name | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | #$tpname = $_; # current filename in that dir | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 7 | $_ = $tree; # current filename in that dir | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | #$wpname = $File::Find::name; # whole pathname to file | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 7 | $File::Find::name = $tree; # unused? xxx | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | 7 | lstat($tree); # set up magic '_' tests | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | 7 | checkm_visit_node(); | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 7 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | #xxx print "tree=$tree, follow_fast=", $find_opt{follow_fast}, "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | $ret = find(\%find_opt, $tree); | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | ▶ | $ret or # if success | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # xxx what does find return? | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | dprint 1, "%error$S", "find returned '$ret' for $tree" if $ret; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # xxx $om->elem('error', "$tree: $o{msg}"); # XXX? | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | #$gr_opt->{om}->elem('filecount', "$filecount file" . | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # ($filecount == 1 ? "" : "s")); | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 5 | dprint 0, "#%checkm_stats$S", | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | "oxum+dinks=$octetcount.$filecount+", | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | "$dircount.$symlinkcount.$irregcount"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | ▶ | $o_verbose and dprint 0, "#%checkm_statstics$S", | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | "$octetcount octet", ($octetcount == 1 ? "" : "s"), | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | ", $filecount file", ($filecount == 1 ? "" : "s"), | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | ", $dircount director", ($dircount == 1 ? "y" : "ies"), | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | ", $symlinkcount link", ($symlinkcount == 1 ? "" : "s"), | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ", $irregcount special file", ($irregcount == 1 ? "" : "s"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | #$gr_opt->{om}->elem('filecount', "$filecount file" . | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # ($filecount == 1 ? "" : "s")); | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 5 | checkm_point(); | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | # a next call to checkm_point includes line above just printed | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 5 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | #use File::Find; | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # $File::Find::prune = 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # XXX add to spec: two ways that a pairpath ends: 1) the form of the | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # ppath (ie, ends in a morty) and 2) you run "aground" smack into | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # a "longy" ("thingy") or a file | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # xxx other stats to gather: total dir count, total count of all things | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # that aren't either reg files or dirs; plus max and averages for all | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # things like depth of ppaths (ids), depth of objects, sizes of objects, | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # fanout; same numbers for "pairtree.*" branches | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 6 | my ($pdname, $tpname, $wpname, $funame); | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | 6 | my $symlinks_followed = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | 6 | my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $sze, $atime, $mtime); | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 6 | ▶ | use Digest; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # returns scalar message string on error or ref to a digester object | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 10 | ▶ | sub make_digester { my( $algname )=@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_digester: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 10 | my $digester; | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | #eval { require $a; import $a }; $@ and print "xxx$@\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # protect us from exceptions | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 10 | eval { $digester = Digest->new($algname); }; | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | 10 | ▶ | $@ and return undef; # $algname not installed | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 10 | return $digester; # success | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # Return formatted list of known digest algorithms | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | sub list_digesters { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_digesters: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my ($a, $digester, @ret); | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | for $a ( qw( MD4/Digest::MD4 | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | MD5/Digest::MD5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | SHA‐256/Digest::SHA2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | SHA‐1/Digest::SHA | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | SHA‐256/Digest::SHA | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | Haval‐256/Digest::Haval256 | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | SHA‐384/Digest::SHA2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | SHA‐384/Digest::SHA | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | SHA‐512/Digest::SHA | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | Whirlpool/Digest::Whirlpool | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | MD2/Digest::MD2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | Adler‐32/Digest::Adler32 | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | CRC‐16/Digest::CRC | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | CRC‐32/Digest::CRC | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | MD5/Digest::Perl::MD5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | CRC‐CCITT/Digest::CRC ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my ($alg, $module) = split('/', $a); | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | # XXXXX why aren't these found ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | #print STDERR "looking for $alg"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $digester = make_digester($alg); | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | unless ($digester) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # print STDERR "--not found\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | next; # $alg not installed | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | #print STDERR "--found\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | undef $digester; | |||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | #eval { | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | # $digester = Digest->new($alg); | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | #}; | ||||||||||||||||||||||||||||||||||||||||||||||
| 274 | #$@ and print("@=$@"), next; # $alg not installed | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | #undef $digester; | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | push @ret, "\t$alg ($module)"; | |||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return @ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | # returns hex digest or string beginning "error:" | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 17 | ▶ | sub digest_file { my( $fname, $digester )=@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
digest_file: called CC=7 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 17 | ▶ | $fname or return "error: no filename given"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 17 | ▶ | $digester or return "error: no Digest object given"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 17 | ▶ | open(FH, "<$fname") or return "error: open <$fname failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 17 | ▶ | binmode(FH) or return "error: binmode failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # xxx catch croaks in addfile, or let go? see perldoc Digest | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 17 | ▶ | $digester->addfile(*FH) or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | close(FH), return "error: Digest->addfile failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 17 | my $digest = $digester->hexdigest; | |||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 17 | ▶ | $digester->reset() or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | close(FH), return "error: Digest->reset failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 17 | close(FH); | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | 17 | return $digest; | |||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # Hex-encode any '|' and '\n' that might appear (in filename) | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 17 | ▶ | sub checkm_encode { my( $s )=@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkm_encode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 17 | $s =~ s/([\n|])/sprintf("%%%02x", ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||
| 306 | 17 | return $s; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 22 | ▶ | sub checkm_time { my( $time )=@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkm_time: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 22 | ▶ | $time ||= time(); # use supplied time or current time | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$time ||= time
MC/DC100%1/1
$time ||= time
$time
Truth table100%2/2
A
A= $time
| |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 22 | my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = | |||||||||||||||||||||||||||||||||||||||||||||
| 313 | gmtime($time); | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 22 | ▶ | return sprintf(($o_temper ? # yyy short temper? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | "%04d.%02d.%02d.%02d:%02d:%02dZ" : | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | "%04d-%02d-%02dT%02d:%02d:%02dZ"), | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | $year + 1900, $mon + 1, $mday, $hour, $min, $sec); | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # XXX add ability to print #%checkm_perm | drwxr-xr-x ... type info | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # $tpname = current filename in directory, $wpname = full pathname | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 17 | ▶ | sub checkm_fileobj { my( $tpname, $wpname, $mtime )=@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkm_fileobj: called CC=17 SCAR=34.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # Initialize checkm line and whether an error as occurred. | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 17 | my $line = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | 17 | my $err = 0; # 0 = no error, 1 = error | |||||||||||||||||||||||||||||||||||||||||||||
| 327 | 17 | my $msg; # what digester returns | |||||||||||||||||||||||||||||||||||||||||||||
| 328 | 17 | ▶ | defined($wpname) or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | die "checkm_fileobj error: wpname arg must be defined"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # yyy should "" or "-" mean stdin? | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 17 | ▶ | unless ($tpname) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $line .= checkm_encode($wpname) . $S . | |||||||||||||||||||||||||||||||||||||||||||||
| 334 | "error: dangling symlink (target doesn't exist)"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | return dprint 1, $line; | |||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 17 | ▶ | unless (-e _) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $line .= checkm_encode($wpname) . $S . | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | "error: file doesn't exist"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | return dprint 1, $line; | |||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 17 | my $fields_left = $o_fieldscount; # how many fields we're to do | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | 17 | ▶ | $fields_left <= 0 and return 1; # print nothing | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 17 | ▶ | $o_fname and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | $fields_left--, | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | ($line .= checkm_encode($wpname)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # else { } # else nothing to do | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 17 | ▶ | $fields_left <= 0 and return dprint $err, $line; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 17 | $line .= $S; | |||||||||||||||||||||||||||||||||||||||||||||
| 353 | 17 | ▶ | $o_aname and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | $fields_left--, | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | ($line .= $o_alg); | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 17 | ▶ | $fields_left <= 0 and return dprint $err, $line; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 17 | $line .= $S; | |||||||||||||||||||||||||||||||||||||||||||||
| 359 | 17 | ▶ | $o_digest and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
$msg =~ /^error:/ and $err ||= 1
$err ||= 1
MC/DC0%0/2
$msg =~ /^error:/ and $err ||= 1
$msg =~ /^error:/
$err
Truth table33%1/3
A and B
A= $msg =~ /^error:/B= $err
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | $fields_left--, | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | ($msg = digest_file($tpname, $o_digester)), | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | ($line .= $msg), # may contain error message | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | ($msg =~ /^error:/ and $err ||= 1); | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 17 | ▶ | $fields_left <= 0 and return dprint $err, $line; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 17 | $line .= $S; | |||||||||||||||||||||||||||||||||||||||||||||
| 367 | 17 | ▶ | $o_size and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | $fields_left--, | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | ($line .= (-s _)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 17 | ▶ | $fields_left <= 0 and return dprint $err, $line; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 17 | $line .= $S; | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | 17 | ▶ | $o_mtime and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | $fields_left--, | ||||||||||||||||||||||||||||||||||||||||||||||
| 375 | ($line .= checkm_time($mtime)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 17 | ▶ | $fields_left <= 0 and return dprint $err, $line; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | return dprint $err, $line; # need this? | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 22 | ▶ | sub checkm_visit_node { # receives no args | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkm_visit_node: called CC=10 SCAR=28.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 22 | $pdname = $File::Find::dir; # current parent directory name | |||||||||||||||||||||||||||||||||||||||||||||
| 384 | 22 | $tpname = $_; # current filename in that dir | |||||||||||||||||||||||||||||||||||||||||||||
| 385 | 22 | $wpname = $File::Find::name; # whole pathname to file | |||||||||||||||||||||||||||||||||||||||||||||
| 386 | 22 | ▶ | $funame = $symlinks_followed ? # full name, symlinks resolved | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 387 | $File::Find::fullname : $wpname; | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | #print "======tp=$tpname, wp=$wpname, pd=$pdname, fn=$File::Find::fullname\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | #print "======fullname=$File::Find::fullname\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # We want to harvest all the inode info for each visit, which | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # usually means stat. Since we want also to know when we have a | ||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # symlink, we actually need lstat. An lstat is done by "find" | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # anyway if following symlinks, so we avoid the work of a real | ||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # lstat on the file and instead call it on the magic handle "_". | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 22 | ▶ | ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $sze, $atime, $mtime) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $funame and () = lstat _
MC/DC50%1/2
defined $funame and () = lstat _
defined $funame
() = lstat _
Truth table66%2/3
A and B
A= defined $funameB= () = lstat _
| |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | = lstat($tpname) | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | #unless ($symlinks_followed and ($sze = -s _)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | unless (defined($funame) and # _ fails if symlink dangles | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $sze, $atime, $mtime) | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | = lstat(_)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | #print "NEXT: $pdname $_ $wpname\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # If we follow symlinks (usual), we have to expect the -l type, | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | # which hides the type of the link target (what we really want). | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 22 | ▶ | if (-l _) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $symlinkcount++; | |||||||||||||||||||||||||||||||||||||||||||||
| 411 | #print "XXXX SYMLINK $wpname\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # yyy presumably this branch never happens when | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # _not_ following links? | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $sze, $atime, | |||||||||||||||||||||||||||||||||||||||||||||
| 415 | $mtime) = stat($tpname); # harvest real file | ||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | unless ($funame) { # bail if dangling link | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | checkm_fileobj($funame, $wpname, $mtime); | |||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | # Now that we have the actual inode info, fall through. | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # After this, tests of the form (-X _) give almost everything. | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # XXX output DLS (+Dirs.Links.Specials) | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 22 | ▶ | if (-f _) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 17 | $filecount++; | |||||||||||||||||||||||||||||||||||||||||||||
| 427 | 17 | $octetcount += $sze; | |||||||||||||||||||||||||||||||||||||||||||||
| 428 | 17 | checkm_fileobj($tpname, $wpname, $mtime); | |||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | elsif (-d _) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 5 | $dircount++; | |||||||||||||||||||||||||||||||||||||||||||||
| 432 | 5 | ▶ | $gr_opt->{long} and checkm_dirobj(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $irregcount++; | |||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | $gr_opt->{long} and checkm_specialobj(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||
| 442 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||