lib/File/Checkm.pm

filter: Statementstmt 84.7% 156 / 184 Branchbran 42.7% 41 / 96 Conditioncond 42.8% 9 / 21 MC/DCmcdc 25.0% 3 / 12 Subroutinesub 88.2% 15 / 17 Podpod 0.0% 0 / 11 totaltotal 65.6% 224 / 341 CC 60 SCAR 28.9
CC
60
Cov
68%
checkm_fileobj
32.5
checkm_trees
26.8
checkm_visit_node
17.5
CRAP 18.0
↑ Summary script/checkm »
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
BranchTrueFalseTotal
s/^pair=([1-9])$/$1/ or push(@unknowns, $_), next 0 0 0
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
BranchTrueFalseTotal
$errtoo and $o_verbose and $ret &&= print(STDERR $output) 0 37 37
Condition16%1/6
$errtoo and $o_verbose
!ll&&!rl&&r
3700
$ret &&= print(STDERR $output)
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
Truth table0%0/3
A &&= B
A= $retB= print(STDERR $output)
ABresult
0X0
100
111
79 37 ▶ $o_mani_digester and $o_mani_digester->add($output);
Branch: 1 branch
BranchTrueFalseTotal
$o_mani_digester and $o_mani_digester->add($output) 37 0 37
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
BranchTrueFalseTotal
$o_mani_digester or return dprint(0, "#%checkm_point$S$S", "$S$manioctets$S", checkm_time()) 5 0 5
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
BranchTrueFalseTotal
ref $r_trees eq "ARRAY" or croak("r_trees must reference an array") 5 0 5
107 croak "r_trees must reference an array";
108 5 ▶ ref($r_opt) eq "HASH" or
Branch: 1 branch
BranchTrueFalseTotal
ref $r_opt eq "HASH" or croak("r_opt must reference a hash (for input/output)") 5 0 5
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
BranchTrueFalseTotal
ref($r_visit_node ||= \&File::Checkm::checkm_visit_node) eq "CODE" or croak("r_visit_node must reference a node-visiting function") 5 0 5
Condition50%1/2
$r_visit_node ||= \&File::Checkm::checkm_visit_node
l!l
05
MC/DC0%0/1
$r_visit_node ||= \&File::Checkm::checkm_visit_node
$r_visit_node
Truth table50%1/2
A
A= $r_visit_node
Aresult
11
00
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
BranchTrueFalseTotal
unless (-e $tree) 0 10 10
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
BranchTrueFalseTotal
if (not -d $tree and $find_opt{"follow_fast"}) 7 3 10
Condition66%2/3
not -d $tree and $find_opt{"follow_fast"}
!ll&&!rl&&r
307
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"}
ABresult
0X0
100
111
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
BranchTrueFalseTotal
$ret or next 0 3 3
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
BranchTrueFalseTotal
if $ret 0 0 0
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
BranchTrueFalseTotal
$o_verbose and dprint(0, "#%checkm_statstics$S", "$octetcount octet", $octetcount == 1 ? "" : "s", ", $filecount file", $filecount == 1 ? "" : "s", ", $dircount director", $dircount == 1 ? "y" : "ies", ", $symlinkcount link", $symlinkcount == 1 ? "" : "s", ", $irregcount special file", $irregcount == 1 ? "" : "s") 0 5 5
$octetcount == 1 ? : 0 0 0
$filecount == 1 ? : 0 0 0
$dircount == 1 ? : 0 0 0
$symlinkcount == 1 ? : 0 0 0
$irregcount == 1 ? : 0 0 0
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
BranchTrueFalseTotal
$@ and return undef 0 10 10
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
BranchTrueFalseTotal
unless ($digester) 0 0 0
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
BranchTrueFalseTotal
$fname or return "error: no filename given" 17 0 17
285 17 ▶ $digester or return "error: no Digest object given";
Branch: 1 branch
BranchTrueFalseTotal
$digester or return "error: no Digest object given" 17 0 17
286 17 ▶ open(FH, "<$fname") or return "error: open <$fname failed: $!";
Branch: 1 branch
BranchTrueFalseTotal
open FH, "<$fname" or return "error: open <$fname failed: $!" 17 0 17
287 17 ▶ binmode(FH) or return "error: binmode failed: $!";
Branch: 1 branch
BranchTrueFalseTotal
binmode FH or return "error: binmode failed: $!" 17 0 17
288  
289 # xxx catch croaks in addfile, or let go? see perldoc Digest
290 17 ▶ $digester->addfile(*FH) or
Branch: 1 branch
BranchTrueFalseTotal
$digester->addfile(*FH) or close FH, (return "error: Digest->addfile failed: $!") 17 0 17
291 close(FH), return "error: Digest->addfile failed: $!";
292  
293 17 my $digest = $digester->hexdigest;
294  
295 17 ▶ $digester->reset() or
Branch: 1 branch
BranchTrueFalseTotal
$digester->reset or close FH, (return "error: Digest->reset failed: $!") 17 0 17
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
l!l
175
MC/DC100%1/1
$time ||= time
$time
Truth table100%2/2
A
A= $time
Aresult
11
00
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
BranchTrueFalseTotal
$o_temper ? : 0 22 22
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
BranchTrueFalseTotal
defined $wpname or die "checkm_fileobj error: wpname arg must be defined" 17 0 17
329 die "checkm_fileobj error: wpname arg must be defined";
330 # yyy should "" or "-" mean stdin?
331
332 17 ▶ unless ($tpname) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tpname) 0 17 17
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
BranchTrueFalseTotal
unless (-e _) 0 17 17
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
BranchTrueFalseTotal
$fields_left <= 0 and return 1 0 17 17
345  
346 17 ▶ $o_fname and
Branch: 1 branch
BranchTrueFalseTotal
$o_fname and --$fields_left, $line .= checkm_encode($wpname) 17 0 17
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
BranchTrueFalseTotal
$fields_left <= 0 and return dprint($err, $line) 0 17 17
351  
352 17 $line .= $S;
353 17 ▶ $o_aname and
Branch: 1 branch
BranchTrueFalseTotal
$o_aname and --$fields_left, $line .= $o_alg 17 0 17
354 $fields_left--,
355 ($line .= $o_alg);
356 17 ▶ $fields_left <= 0 and return dprint $err, $line;
Branch: 1 branch
BranchTrueFalseTotal
$fields_left <= 0 and return dprint($err, $line) 0 17 17
357  
358 17 $line .= $S;
359 17 ▶ $o_digest and
Branch: 1 branch
BranchTrueFalseTotal
$o_digest and --$fields_left, $msg = digest_file($tpname, $o_digester), $line .= $msg, $msg =~ /^error:/ && ($err ||= 1) 17 0 17
Condition20%1/5
$msg =~ /^error:/ and $err ||= 1
!ll&&!rl&&r
1700
$err ||= 1
l!l
00
MC/DC0%0/2
$msg =~ /^error:/ and $err ||= 1
$msg =~ /^error:/ $err
Truth table33%1/3
A and B
A= $msg =~ /^error:/B= $err
ABresult
0X0
100
111
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
BranchTrueFalseTotal
$fields_left <= 0 and return dprint($err, $line) 0 17 17
365  
366 17 $line .= $S;
367 17 ▶ $o_size and
Branch: 1 branch
BranchTrueFalseTotal
$o_size and --$fields_left, $line .= -s(_) 17 0 17
368 $fields_left--,
369 ($line .= (-s _));
370 17 ▶ $fields_left <= 0 and return dprint $err, $line;
Branch: 1 branch
BranchTrueFalseTotal
$fields_left <= 0 and return dprint($err, $line) 0 17 17
371  
372 17 $line .= $S;
373 17 ▶ $o_mtime and
Branch: 1 branch
BranchTrueFalseTotal
$o_mtime and --$fields_left, $line .= checkm_time($mtime) 17 0 17
374 $fields_left--,
375 ($line .= checkm_time($mtime));
376 17 ▶ $fields_left <= 0 and return dprint $err, $line;
Branch: 1 branch
BranchTrueFalseTotal
$fields_left <= 0 and return dprint($err, $line) 17 0 17
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
BranchTrueFalseTotal
$symlinks_followed ? : 22 0 22
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
BranchTrueFalseTotal
unless defined $funame and () = lstat _ 7 15 22
Condition66%2/3
defined $funame and () = lstat _
!ll&&!rl&&r
7015
MC/DC50%1/2
defined $funame and () = lstat _
defined $funame () = lstat _
Truth table66%2/3
A and B
A= defined $funameB= () = lstat _
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if (-l _) 0 22 22
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
BranchTrueFalseTotal
unless ($funame) 0 0 0
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
BranchTrueFalseTotal
if (-f _) { } 17 5 22
elsif (-d _) { } 5 0 5
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
BranchTrueFalseTotal
$gr_opt->{"long"} and checkm_dirobj() 0 5 5
433 }
434 else {
435 0 $irregcount++;
436 0 ▶ $gr_opt->{long} and checkm_specialobj();
Branch: 1 branch
BranchTrueFalseTotal
$gr_opt->{"long"} and checkm_specialobj() 0 0 0
437 }
438 }
439  
440 6 1;
441  
442 __END__
↑ Summary script/checkm »