Branch Coverage

lib/File/Util.pm
Criterion Covered Total %
branch 382 698 54.7


line true false branch
56 3 21 if exists $in->{'use_flock'} and defined $in->{'use_flock'}
62 0 24 if exists $in->{'diag'} and defined $in->{'diag'}
70 2 21 defined $in->{'readlimit'} ? :
1 23 defined $in->{'read_limit'} ? :
73 21 3 unless defined $in->{'read_limit'}
78 3 0 if exists $in->{'read_limit'} and defined $in->{'read_limit'} and not $in->{'read_limit'} =~ /\D/
85 3 0 if exists $in->{'abort_depth'} and defined $in->{'abort_depth'} and not $in->{'abort_depth'} =~ /\D/
100 0 22 if grep {/(?
112 48 32 ref $_[0] eq 'REF' ? :
125 32 48 unless ($opts->{'_recursing'})
127 0 32 unless defined $dir and length $dir
140 32 0 defined $this->{'opts'}{'abort_depth'} ? :
0 32 defined $opts->{'abort_depth'} ? :
143 32 0 unless $dir =~ /^$File::Util::WINROOT$/o
146 0 32 if $opts->{'recurse_fast'} or $opts->{'follow'}
149 25 7 if $opts->{'recurse'}
152 0 32 if $opts->{'maxdepth'}
155 0 32 if $opts->{'as_tree'}
157 0 32 unless -e $dir
160 0 32 unless -d $dir
179 0 32 $dir eq '/' || $dir =~ /^$File::Util::WINROOT/ ? :
32 48 unless defined $opts->{'_recursion'}
183 80 0 unless ($opts->{'_recursion'}{'_fast'})
187 80 0 if ($inode)
198 0 80 if exists $opts->{'_recursion'}{'_inodes'}{join $;, $dev, $inode}
212 0 80 if ($opts->{'_recursion'}{'_isroot'}) { }
223 80 0 if ($File::Util::SL eq '/') { }
225 48 32 if defined $trailing_dirs
230 0 0 if defined $trailing_dirs
236 0 80 if $opts->{'max_depth'} and $opts->{'_recursion'}{'_depth'} >= $opts->{'max_depth'}
246 0 80 if $opts->{'_recursion'}{'_depth'} == $abort_depth and $abort_depth != 0
250 0 80 unless opendir my $dir_fh, $dir
268 0 80 defined $opts->{'pattern'} ? :
276 32 16 unless -d $dir . '/' . $_
6 74 defined $opts->{'rpattern'} ? :
279 0 80 unless closedir $dir_fh
290 73 7 if ($opts->{'no_fsdots'})
292 4 69 if ($dir_contents[0] eq '.' and $dir_contents[1] eq '..') { }
304 80 0 $dir ne '/' && !($dir =~ /^$File::Util::WINROOT$/) ? :
313 66 396 if (-d $dir_base . $dir_entry and not -l $dir_base . $dir_entry) { }
321 32 48 unless (defined $opts->{'_matching'})
332 51 29 if ($opts->{'_matching'})
341 73 7 if ($opts->{'recurse'} or $opts->{'with_paths'})
351 5 75 if (my $cb = $opts->{'callback'})
353 0 5 unless ref $cb eq 'CODE'
359 0 80 if (my $cb = $opts->{'d_callback'})
361 0 0 unless ref $cb eq 'CODE'
367 0 80 if (my $cb = $opts->{'f_callback'})
369 0 0 unless ref $cb eq 'CODE'
376 25 55 if ($opts->{'recurse'} and not $opts->{'max_depth'} && $opts->{'_recursion'}{'_depth'} == $opts->{'max_depth'} - 1)
417 48 0 if ref $dirs_ref and ref $dirs_ref eq 'ARRAY'
420 48 0 if ref $files_ref and ref $files_ref eq 'ARRAY'
427 10 22 if (not $opts->{'_recursing'} and $opts->{'path_matches'} || $opts->{'parent_matches'})
437 0 80 if ($opts->{'sl_after_dirs'})
444 0 80 if ($opts->{'ignore_case'}) { }
458 0 3 if $opts->{'dirs_only'} and $opts->{'count_only'}
461 0 18 if $opts->{'files_only'} and $opts->{'count_only'}
464 0 80 if $opts->{'count_only'}
467 48 32 if $opts->{'as_ref'}
469 0 32 if $opts->{'dirs_as_ref'}
470 0 32 if $opts->{'files_as_ref'}
472 3 29 if $opts->{'dirs_only'}
473 18 11 if $opts->{'files_only'}
492 17 34 unless defined $opts->{'_patterns'}{'_files_match_and'}
497 17 34 unless defined $opts->{'_patterns'}{'_files_match_or'}
502 17 34 unless defined $opts->{'_patterns'}{'_dirs_match_and'}
507 17 34 unless defined $opts->{'_patterns'}{'_dirs_match_or'}
512 17 34 unless defined $opts->{'_patterns'}{'_parent_matches_and'}
517 17 34 unless defined $opts->{'_patterns'}{'_parent_matches_or'}
522 17 34 unless defined $opts->{'_patterns'}{'_path_matches_and'}
527 17 34 unless defined $opts->{'_patterns'}{'_path_matches_or'}
538 27 24 if @{$opts->{'_patterns'}{'_files_match_and'};}
541 3 48 if @{$opts->{'_patterns'}{'_files_match_or'};}
546 6 45 if @{$opts->{'_patterns'}{'_dirs_match_and'};}
549 6 45 if @{$opts->{'_patterns'}{'_dirs_match_or'};}
553 9 21 if ($opts->{'files_match'} and $opts->{'dirs_match'})
559 1 8 unless _match_and($opts->{'_patterns'}{'_dirs_match_and'}, [strip_path($path)])
565 15 36 if ($opts->{'parent_matches'})
567 12 3 if (@{$opts->{'_patterns'}{'_parent_matches_and'};}) { }
3 0 elsif (@{$opts->{'_patterns'}{'_parent_matches_or'};}) { }
573 6 6 unless _match_and($opts->{'_patterns'}{'_parent_matches_and'}, [strip_path($path)])
582 0 3 unless _match_or($opts->{'_patterns'}{'_parent_matches_or'}, [strip_path($path)])
589 15 36 if ($opts->{'path_matches'})
591 9 6 if (@{$opts->{'_patterns'}{'_path_matches_and'};}) { }
6 0 elsif (@{$opts->{'_patterns'}{'_path_matches_or'};}) { }
596 7 2 unless _match_and($opts->{'_patterns'}{'_path_matches_and'}, [$path])
604 2 4 unless _match_or($opts->{'_patterns'}{'_path_matches_or'}, [$path])
623 5 5 if ($opts->{'parent_matches'})
627 4 1 if (@{$opts->{'_patterns'}{'_parent_matches_and'};}) { }
1 0 elsif (@{$opts->{'_patterns'}{'_parent_matches_or'};}) { }
633 8 0 if $root
639 2 6 if _match_and($opts->{'_patterns'}{'_parent_matches_and'}, [strip_path($in_path)])
649 2 0 if $root
655 2 0 if _match_or($opts->{'_patterns'}{'_parent_matches_or'}, [strip_path($in_path)])
665 5 5 if ($opts->{'path_matches'})
669 3 2 if (@{$opts->{'_patterns'}{'_path_matches_and'};}) { }
2 0 elsif (@{$opts->{'_patterns'}{'_path_matches_or'};}) { }
675 6 0 if $root
680 0 6 if _match_and($opts->{'_patterns'}{'_path_matches_and'}, [$in_path])
686 2 4 if _match_and($opts->{'_patterns'}{'_path_matches_and'}, [$qfd_dir])
696 4 0 if $root
701 2 2 if _match_or($opts->{'_patterns'}{'_path_matches_or'}, [$in_path])
707 4 0 if _match_or($opts->{'_patterns'}{'_path_matches_or'}, [$qfd_dir])
731 11 50 defined $pattern_ref && ref $pattern_ref eq 'Regexp' ? :
7 61 defined $pattern_ref && ref $pattern_ref eq 'HASH' && defined $pattern_ref->{'and'} && ref $pattern_ref->{'and'} eq 'ARRAY' ? :
751 6 62 defined $pattern_ref && ref $pattern_ref eq 'HASH' && defined $pattern_ref->{'or'} && ref $pattern_ref->{'or'} eq 'ARRAY' ? :
783 28 28 $or_pattern ? :
815 0 0 if $root
825 0 0 $i > 0 ? :
827 0 0 if (defined $parent)
832 0 0 if @predecessors > 1 and $predecessors[0] eq '/'
838 0 0 if $root and $parent ne $root
843 0 0 unless (exists $opts->{'dirmeta'} and defined $opts->{'dirmeta'} and $opts->{'dirmeta'} == 0)
851 0 0 $parent eq $root ? :
0 0 !defined($parent) ? :
899 1 0 if push @out, @copy
1 2 if ($gottadot == 2)
903 2 0 if ($dir_item =~ /$File::Util::FSDOTS/)
915 0 1 if $opts->{'save_dots'}
943 0 56 defined $in->{'readlimit'} ? :
0 56 defined $in->{'read_limit'} ? :
946 56 0 unless defined $in->{'read_limit'}
953 0 0 defined $File::Util::READ_LIMIT ? :
56 0 defined $this->{'opts'}{'read_limit'} ? :
0 56 defined $in->{'read_limit'} ? :
957 0 56 if $read_limit =~ /\D/
962 0 56 if defined $in->{'file_handle'}
964 56 0 if (not defined $in->{'FH'}) { }
970 0 56 defined $in->{'filename'} ? :
0 56 defined $in->{'file'} ? :
972 0 56 unless length $file
985 56 0 if $root
991 0 56 if (not length $root || length $path) { }
1006 0 0 if (ref $in->{'FH'} eq 'GLOB') { }
1023 0 56 if ($fh_passed)
1031 0 0 if ($buffer < $read_limit) { }
1055 0 0 if $in->{'as_list'}
1061 0 56 unless -e $clean_name
1074 0 56 unless -r $root . $path
1084 0 56 unless -r $clean_name
1094 0 56 if -d $clean_name
1104 0 56 if $fsize > $read_limit
1122 0 56 if ($in->{'no_lock'} or $this->{'opts'}{'no_lock'} or not $this->use_flock) { }
1129 0 0 unless open $fh, '<', $clean_name
1142 0 56 unless open $fh, '<', $clean_name
1160 3 53 if -B $clean_name
1163 4 52 if ($in->{'binmode'})
1165 4 0 if (lc $in->{'binmode'} eq 'utf8') { }
0 0 elsif ($in->{'binmode'} == 1) { }
1167 4 0 if ($File::Util::HAVE_UU) { }
1194 0 56 if ($in->{'no_lock'} or $this->{'opts'}{'no_lock'}) { }
1199 0 0 unless close $fh
1213 0 56 unless close $fh
1228 0 56 if $in->{'as_lines'}
1260 28 44 exists $in->{'file'} && defined $in->{'file'} && length $in->{'file'} ? :
1 72 exists $in->{'filename'} && defined $in->{'filename'} && length $in->{'filename'} ? :
1264 0 73 unless defined $maybe_file
1265 26 47 unless defined $maybe_content
1267 44 29 if not ref $maybe_file and $file eq ''
1272 46 27 !(ref $maybe_content || exists $in->{'content'}) ? :
1278 73 0 unless $file eq '/'
1279 0 73 if $winroot
1285 0 73 if $mode eq 'truncate'
1286 2 71 if $mode eq 'trunc'
1290 0 73 unless length $file
1317 0 25 if !defined($content) || length $content == 0 and $mode ne 'trunc' and not $File::Util::EMPTY_WRITES_OK and not $in->{'empty_writes_OK'} and not $in->{'empty_writes_ok'}
1320 0 73 if -d $raw_name
1334 0 232 unless $this->valid_filename($_)
1344 73 0 if $root
1347 0 10 unless ($mode eq 'write' or $mode eq 'append' or $mode eq 'trunc')
1363 0 73 if (not length $root || length $path) { }
1376 0 73 unless (-e $root . $path)
1393 0 0 if ref $in->{'onfail'} and ref $in->{'onfail'} eq 'CODE'
1400 0 0 exists $in->{'dbitmask'} && defined $in->{'dbitmask'} ? :
1402 0 0 unless $make_dir_ok
1406 22 51 if (-e $clean_name) { }
1408 0 22 unless -w $clean_name
1419 0 51 unless -w $root . $path
1430 0 73 if ($in->{'no_lock'} or not $File::Util::USE_FLOCK) { }
1433 0 0 if (-e $clean_name) { }
1437 0 0 if ($in->{'binmode'} and lc $in->{'binmode'} eq 'utf8') { }
1441 0 0 unless open $write_fh, $File::Util::MODES->{'popen'}{$mode}, $clean_name
1458 0 0 unless sysopen $write_fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}
1475 0 0 unless sysopen $write_fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}, $bitmask
1491 22 51 if (-e $clean_name) { }
1493 0 22 unless open $write_fh, '<', $clean_name
1507 0 22 unless $lockstat
1511 2 20 if ($in->{'binmode'} and lc $in->{'binmode'} eq 'utf8') { }
1515 0 2 unless open $write_fh, $File::Util::MODES->{'popen'}{$mode}, $clean_name
1532 0 20 unless sysopen $write_fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}
1549 0 51 if ($in->{'binmode'} and lc $in->{'binmode'} eq 'utf8') { }
1553 0 0 unless open $write_fh, $File::Util::MODES->{'popen'}{$mode}, $clean_name
1570 0 51 unless sysopen $write_fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}, $bitmask
1586 0 51 unless $lockstat
1590 65 8 if ($mode ne 'append')
1592 0 65 unless truncate $write_fh, 0
1602 2 71 if ($in->{'binmode'}) { }
1604 2 0 if (lc $in->{'binmode'} eq 'utf8') { }
0 0 elsif ($in->{'binmode'} == 1) { }
1606 2 0 if ($File::Util::HAVE_UU) { }
1639 72 0 unless $in->{'no_lock'} or not $File::Util::USE_FLOCK
1641 0 72 unless close $write_fh
1661 0 134 unless $fh
1664 134 0 defined $file ? :
1666 0 134 unless length $file
1670 0 134 unless $File::Util::CAN_FLOCK
1680 134 1 if $fh or not scalar @policy
1694 0 128 unless $fh and ref $fh eq 'GLOB'
1698 128 0 if ($File::Util::CAN_FLOCK)
1711 314 15 !($f =~ /$File::Util::ILLEGAL_CHR/) ? :
1723 123 0 if defined $stripped
1756 0 0 if $root
1757 0 0 if $leaf
1772 0 2 unless open my $fh, '<', $file
1802 5 0 -e $f ? :
5 0 if defined $f
1821 1 0 defined $f ? :
1822 5 0 defined $f ? :
1831 5 0 -e $f ? :
5 0 if defined $f
1847 0 2 unless defined $file
1849 1 1 unless defined $escape
1851 1 1 if ($also)
1863 2 0 defined $f ? :
1875 0 26 unless defined $file and length $file
1887 0 26 if -e $file and -d $file
1901 0 26 if -e $path and not -r $path
1910 1 25 unless -e $path
1916 25 1 unless -e $file
1931 0 8 unless defined $f and -e $f
1935 2 6 if -f $f
1 7 if -T $f
1936 7 1 if -B $f
6 2 if -d $f
1937 0 8 if -l $f
0 8 if -p $f
1938 0 8 if -S $f
0 8 if -b $f
1939 0 8 if -c $f
1942 0 8 if -t $f
1945 0 8 unless scalar @ret
1958 2 3 unless scalar @rules
1973 0 6 unless exists $valid{$_}
1985 2 0 defined $f ? :
1994 0 5 unless -e $f
2007 0 5 unless -e $f
2020 0 2 unless -e $f
2041 0 6 unless length $dir
2053 1 5 if (not $opts->{'as_list'} || $opts->{'as_listref'}) { }
2069 4 1 if $opts->{'as_listref'}
2086 0 10 defined $bitmask ? :
2091 0 10 unless defined $dir and length $dir
2100 2 8 if ($opts->{'if_not_exists'}) { }
2102 0 2 if (-e $dir)
2104 0 0 if -d $dir
2118 0 8 if (-e $dir)
2120 0 0 unless -d $dir
2144 10 0 unless $dir eq '/'
2145 0 10 if $winroot
2154 0 50 unless $this->valid_filename($_)
2165 10 0 if $root
2171 10 0 if (@dirs_in_path > 1)
2174 10 40 if ($dirs_in_path[$depth - 1] eq '/') { }
2190 50 10 $i > 0 ? :
2194 0 60 if (-e $dir and not -d $dir)
2206 40 20 if -e $dir
2211 0 20 unless -w $up
2220 0 20 unless mkdir $dir, $bitmask
2243 0 3 if (defined $arg)
2245 0 0 if $arg =~ /\D/
2251 0 0 if &blessed($this) and $this->{'opts'}
2263 0 0 unless &blessed($this)
2265 0 0 if $arg
2278 0 5 if (defined $arg)
2280 0 0 if $arg =~ /\D/
2286 0 0 if &blessed($this) and $this->{'opts'}
2300 0 0 if (defined $arg)
2302 0 0 $arg ? :
2305 0 0 $arg ? :
0 0 if &blessed($this) and $this->{'opts'}
2343 1 4 exists $in->{'file'} && defined $in->{'file'} && length $in->{'file'} ? :
0 5 exists $in->{'filename'} && defined $in->{'filename'} && length $in->{'filename'} ? :
2347 0 5 unless defined $maybe_file
2348 0 5 unless defined $maybe_mode
2350 4 1 if not ref $maybe_file and $file eq ''
2355 4 1 !(ref $maybe_mode || exists $in->{'mode'}) ? :
2364 5 0 unless $file eq '/'
2365 0 5 if $winroot
2375 0 5 unless length $file
2384 0 5 if ($mode eq 'read' and not -e $raw_name)
2387 0 0 unless -e $clean_name
2403 0 5 if $try_filename =~ /(?:$File::Util::DIRSPLIT){2,}/
2420 0 8 unless $this->valid_filename($_)
2431 5 0 if $root
2434 5 0 if (not exists $in->{'use_sysopen'} || defined $in->{'use_sysopen'}) { }
2439 0 5 unless (exists $File::Util::MODES->{'popen'}{$mode} and defined $File::Util::MODES->{'popen'}{$mode})
2456 0 0 unless (exists $File::Util::MODES->{'sysopen'}{$mode} and defined $File::Util::MODES->{'sysopen'}{$mode})
2476 0 5 if (not length $root || length $path) { }
2489 0 5 if ($mode ne 'read' and not -e $root . $path)
2506 0 0 if ref $in->{'onfail'} and ref $in->{'onfail'} eq 'CODE'
2513 0 0 exists $in->{'dbitmask'} && defined $in->{'dbitmask'} ? :
2515 0 0 unless $make_dir_ok
2519 4 1 if ($mode eq 'write' or $mode eq 'append' or $mode eq 'rwcreate' or $mode eq 'rwclobber' or $mode eq 'rwappend') { }
1 0 elsif ($mode eq 'read' or $mode eq 'rwupdate') { }
2529 3 1 if (-e $clean_name) { }
2531 0 3 unless -w $clean_name
2543 0 1 unless -w $root . $path
2556 0 1 unless -r $root . $path
2566 0 1 unless -e $clean_name
2576 0 1 unless -r $clean_name
2599 0 0 if (exists $in->{'use_sysopen'} and defined $in->{'use_sysopen'} and ($in->{'binmode'} and lc $in->{'binmode'} eq 'utf8'))
2618 0 5 if ($in->{'no_lock'} or not $File::Util::USE_FLOCK) { }
2619 0 0 if (not exists $in->{'use_sysopen'} || defined $in->{'use_sysopen'}) { }
2626 0 0 unless open $fh, $mode, $clean_name
2642 0 0 unless sysopen $fh, $clean_name, $mode
2656 5 0 if (not exists $in->{'use_sysopen'} || defined $in->{'use_sysopen'}) { }
2661 4 1 if (-e $clean_name) { }
2663 0 4 unless open $fh, '<', $clean_name
2678 1 3 unless fileno $lockstat
2680 2 1 if ($mode ne 'read')
2690 0 2 unless open $fh, $File::Util::MODES->{'popen'}{$mode}, $clean_name
2704 0 1 unless open $fh, $File::Util::MODES->{'popen'}{$mode}, $clean_name
2711 0 1 unless $lockstat
2716 0 0 if (-e $clean_name) { }
2718 0 0 unless open $fh, '<', $clean_name
2733 0 0 unless $lockstat
2735 0 0 unless sysopen $fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}
2751 0 0 unless sysopen $fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}, $bitmask
2767 0 0 unless $lockstat
2773 2 2 if ($in->{'binmode'})
2775 2 0 if (lc $in->{'binmode'} eq 'utf8') { }
0 0 elsif ($in->{'binmode'} == 1) { }
2777 2 0 if ($File::Util::HAVE_UU) { }
2809 0 2 unless $File::Util::USE_FLOCK
2811 0 2 unless $fh and fileno $fh
2818 2 0 if $File::Util::CAN_FLOCK
2840 0 0 unless defined $path
2842 0 0 unless defined $path
2844 0 0 unless substr $path, -1, 1 =~ /$File::Util::DIRSPLIT/
2846 0 0 $path =~ /$File::Util::DIRSPLIT/ ? :
2857 0 0 defined $dflt ? :
2861 0 0 defined $path ? :
2868 0 5 unless -e $f
2883 3 61 if defined $arg
2916 1 1 if ($name eq '_throw') { }
1 0 elsif (exists $redirect_methods->{$name}) { }
2931 0 1 $in->{'diag'} ? :
0 1 defined $in->{'diag'} && !$in->{'diag'} ? :
2933 0 1 if ($in->{'diag'} or $in->{'opts'} and ref $in->{'opts'} and ref $in->{'opts'} eq 'HASH' and $in->{'opts'}{'diag'}) { }