Branch Coverage

lib/File/Util.pm
Criterion Covered Total %
branch 381 698 54.5


line true false branch
58 3 21 if exists $in->{'use_flock'} and defined $in->{'use_flock'}
64 0 24 if exists $in->{'diag'} and defined $in->{'diag'}
72 2 21 defined $in->{'readlimit'} ? :
1 23 defined $in->{'read_limit'} ? :
75 21 3 unless defined $in->{'read_limit'}
80 3 0 if exists $in->{'read_limit'} and defined $in->{'read_limit'} and not $in->{'read_limit'} =~ /\D/
87 3 0 if exists $in->{'abort_depth'} and defined $in->{'abort_depth'} and not $in->{'abort_depth'} =~ /\D/
102 0 22 if grep {/(?
114 48 32 ref $_[0] eq 'REF' ? :
127 32 48 unless ($opts->{'_recursing'})
129 0 32 unless defined $dir and length $dir
142 32 0 defined $this->{'opts'}{'abort_depth'} ? :
0 32 defined $opts->{'abort_depth'} ? :
145 32 0 unless $dir =~ /^$File::Util::WINROOT$/o
148 0 32 if $opts->{'recurse_fast'} or $opts->{'follow'}
151 25 7 if $opts->{'recurse'}
154 0 32 if $opts->{'maxdepth'}
157 0 32 if $opts->{'as_tree'}
159 0 32 unless -e $dir
162 0 32 unless -d $dir
181 0 32 $dir eq '/' || $dir =~ /^$File::Util::WINROOT/ ? :
32 48 unless defined $opts->{'_recursion'}
185 80 0 unless ($opts->{'_recursion'}{'_fast'})
189 80 0 if ($inode)
200 0 80 if exists $opts->{'_recursion'}{'_inodes'}{join $;, $dev, $inode}
214 0 80 if ($opts->{'_recursion'}{'_isroot'}) { }
225 80 0 if ($File::Util::SL eq '/') { }
227 48 32 if defined $trailing_dirs
232 0 0 if defined $trailing_dirs
238 0 80 if $opts->{'max_depth'} and $opts->{'_recursion'}{'_depth'} >= $opts->{'max_depth'}
248 0 80 if $opts->{'_recursion'}{'_depth'} == $abort_depth and $abort_depth != 0
252 0 80 unless opendir my $dir_fh, $dir
270 0 80 defined $opts->{'pattern'} ? :
278 32 16 unless -d $dir . '/' . $_
6 74 defined $opts->{'rpattern'} ? :
281 0 80 unless closedir $dir_fh
292 73 7 if ($opts->{'no_fsdots'})
294 0 73 if ($dir_contents[0] eq '.' and $dir_contents[1] eq '..') { }
306 80 0 $dir ne '/' && !($dir =~ /^$File::Util::WINROOT$/) ? :
315 66 396 if (-d $dir_base . $dir_entry and not -l $dir_base . $dir_entry) { }
323 32 48 unless (defined $opts->{'_matching'})
334 51 29 if ($opts->{'_matching'})
343 73 7 if ($opts->{'recurse'} or $opts->{'with_paths'})
353 5 75 if (my $cb = $opts->{'callback'})
355 0 5 unless ref $cb eq 'CODE'
361 0 80 if (my $cb = $opts->{'d_callback'})
363 0 0 unless ref $cb eq 'CODE'
369 0 80 if (my $cb = $opts->{'f_callback'})
371 0 0 unless ref $cb eq 'CODE'
378 25 55 if ($opts->{'recurse'} and not $opts->{'max_depth'} && $opts->{'_recursion'}{'_depth'} == $opts->{'max_depth'} - 1)
419 48 0 if ref $dirs_ref and ref $dirs_ref eq 'ARRAY'
422 48 0 if ref $files_ref and ref $files_ref eq 'ARRAY'
429 10 22 if (not $opts->{'_recursing'} and $opts->{'path_matches'} || $opts->{'parent_matches'})
439 0 80 if ($opts->{'sl_after_dirs'})
446 0 80 if ($opts->{'ignore_case'}) { }
460 0 3 if $opts->{'dirs_only'} and $opts->{'count_only'}
463 0 18 if $opts->{'files_only'} and $opts->{'count_only'}
466 0 80 if $opts->{'count_only'}
469 48 32 if $opts->{'as_ref'}
471 0 32 if $opts->{'dirs_as_ref'}
472 0 32 if $opts->{'files_as_ref'}
474 3 29 if $opts->{'dirs_only'}
475 18 11 if $opts->{'files_only'}
494 17 34 unless defined $opts->{'_patterns'}{'_files_match_and'}
499 17 34 unless defined $opts->{'_patterns'}{'_files_match_or'}
504 17 34 unless defined $opts->{'_patterns'}{'_dirs_match_and'}
509 17 34 unless defined $opts->{'_patterns'}{'_dirs_match_or'}
514 17 34 unless defined $opts->{'_patterns'}{'_parent_matches_and'}
519 17 34 unless defined $opts->{'_patterns'}{'_parent_matches_or'}
524 17 34 unless defined $opts->{'_patterns'}{'_path_matches_and'}
529 17 34 unless defined $opts->{'_patterns'}{'_path_matches_or'}
540 27 24 if @{$opts->{'_patterns'}{'_files_match_and'};}
543 3 48 if @{$opts->{'_patterns'}{'_files_match_or'};}
548 6 45 if @{$opts->{'_patterns'}{'_dirs_match_and'};}
551 6 45 if @{$opts->{'_patterns'}{'_dirs_match_or'};}
555 9 21 if ($opts->{'files_match'} and $opts->{'dirs_match'})
561 1 8 unless _match_and($opts->{'_patterns'}{'_dirs_match_and'}, [strip_path($path)])
567 15 36 if ($opts->{'parent_matches'})
569 12 3 if (@{$opts->{'_patterns'}{'_parent_matches_and'};}) { }
3 0 elsif (@{$opts->{'_patterns'}{'_parent_matches_or'};}) { }
575 6 6 unless _match_and($opts->{'_patterns'}{'_parent_matches_and'}, [strip_path($path)])
584 0 3 unless _match_or($opts->{'_patterns'}{'_parent_matches_or'}, [strip_path($path)])
591 15 36 if ($opts->{'path_matches'})
593 9 6 if (@{$opts->{'_patterns'}{'_path_matches_and'};}) { }
6 0 elsif (@{$opts->{'_patterns'}{'_path_matches_or'};}) { }
598 7 2 unless _match_and($opts->{'_patterns'}{'_path_matches_and'}, [$path])
606 2 4 unless _match_or($opts->{'_patterns'}{'_path_matches_or'}, [$path])
625 5 5 if ($opts->{'parent_matches'})
629 4 1 if (@{$opts->{'_patterns'}{'_parent_matches_and'};}) { }
1 0 elsif (@{$opts->{'_patterns'}{'_parent_matches_or'};}) { }
635 8 0 if $root
641 2 6 if _match_and($opts->{'_patterns'}{'_parent_matches_and'}, [strip_path($in_path)])
651 2 0 if $root
657 2 0 if _match_or($opts->{'_patterns'}{'_parent_matches_or'}, [strip_path($in_path)])
667 5 5 if ($opts->{'path_matches'})
671 3 2 if (@{$opts->{'_patterns'}{'_path_matches_and'};}) { }
2 0 elsif (@{$opts->{'_patterns'}{'_path_matches_or'};}) { }
677 6 0 if $root
682 0 6 if _match_and($opts->{'_patterns'}{'_path_matches_and'}, [$in_path])
688 2 4 if _match_and($opts->{'_patterns'}{'_path_matches_and'}, [$qfd_dir])
698 4 0 if $root
703 2 2 if _match_or($opts->{'_patterns'}{'_path_matches_or'}, [$in_path])
709 4 0 if _match_or($opts->{'_patterns'}{'_path_matches_or'}, [$qfd_dir])
733 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' ? :
753 6 62 defined $pattern_ref && ref $pattern_ref eq 'HASH' && defined $pattern_ref->{'or'} && ref $pattern_ref->{'or'} eq 'ARRAY' ? :
785 28 28 $or_pattern ? :
817 0 0 if $root
827 0 0 $i > 0 ? :
829 0 0 if (defined $parent)
834 0 0 if @predecessors > 1 and $predecessors[0] eq '/'
840 0 0 if $root and $parent ne $root
845 0 0 unless (exists $opts->{'dirmeta'} and defined $opts->{'dirmeta'} and $opts->{'dirmeta'} == 0)
853 0 0 $parent eq $root ? :
0 0 !defined($parent) ? :
901 1 0 if push @out, @copy
1 2 if ($gottadot == 2)
905 2 0 if ($dir_item =~ /$File::Util::FSDOTS/)
917 0 1 if $opts->{'save_dots'}
945 0 56 defined $in->{'readlimit'} ? :
0 56 defined $in->{'read_limit'} ? :
948 56 0 unless defined $in->{'read_limit'}
955 0 0 defined $File::Util::READ_LIMIT ? :
56 0 defined $this->{'opts'}{'read_limit'} ? :
0 56 defined $in->{'read_limit'} ? :
959 0 56 if $read_limit =~ /\D/
964 0 56 if defined $in->{'file_handle'}
966 56 0 if (not defined $in->{'FH'}) { }
972 0 56 defined $in->{'filename'} ? :
0 56 defined $in->{'file'} ? :
974 0 56 unless length $file
987 56 0 if $root
993 0 56 if (not length $root || length $path) { }
1008 0 0 if (ref $in->{'FH'} eq 'GLOB') { }
1025 0 56 if ($fh_passed)
1033 0 0 if ($buffer < $read_limit) { }
1057 0 0 if $in->{'as_list'}
1063 0 56 unless -e $clean_name
1076 0 56 unless -r $root . $path
1086 0 56 unless -r $clean_name
1096 0 56 if -d $clean_name
1106 0 56 if $fsize > $read_limit
1124 0 56 if ($in->{'no_lock'} or $this->{'opts'}{'no_lock'} or not $this->use_flock) { }
1131 0 0 unless open $fh, '<', $clean_name
1144 0 56 unless open $fh, '<', $clean_name
1162 3 53 if -B $clean_name
1165 4 52 if ($in->{'binmode'})
1167 4 0 if (lc $in->{'binmode'} eq 'utf8') { }
0 0 elsif ($in->{'binmode'} == 1) { }
1169 4 0 if ($File::Util::HAVE_UU) { }
1196 0 56 if ($in->{'no_lock'} or $this->{'opts'}{'no_lock'}) { }
1201 0 0 unless close $fh
1215 0 56 unless close $fh
1230 0 56 if $in->{'as_lines'}
1262 28 44 exists $in->{'file'} && defined $in->{'file'} && length $in->{'file'} ? :
1 72 exists $in->{'filename'} && defined $in->{'filename'} && length $in->{'filename'} ? :
1266 0 73 unless defined $maybe_file
1267 26 47 unless defined $maybe_content
1269 44 29 if not ref $maybe_file and $file eq ''
1274 46 27 !(ref $maybe_content || exists $in->{'content'}) ? :
1280 73 0 unless $file eq '/'
1281 0 73 if $winroot
1287 0 73 if $mode eq 'truncate'
1288 2 71 if $mode eq 'trunc'
1292 0 73 unless length $file
1319 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'}
1322 0 73 if -d $raw_name
1336 0 232 unless $this->valid_filename($_)
1346 73 0 if $root
1349 0 10 unless ($mode eq 'write' or $mode eq 'append' or $mode eq 'trunc')
1365 0 73 if (not length $root || length $path) { }
1378 0 73 unless (-e $root . $path)
1395 0 0 if ref $in->{'onfail'} and ref $in->{'onfail'} eq 'CODE'
1402 0 0 exists $in->{'dbitmask'} && defined $in->{'dbitmask'} ? :
1404 0 0 unless $make_dir_ok
1408 22 51 if (-e $clean_name) { }
1410 0 22 unless -w $clean_name
1421 0 51 unless -w $root . $path
1432 0 73 if ($in->{'no_lock'} or not $File::Util::USE_FLOCK) { }
1435 0 0 if (-e $clean_name) { }
1439 0 0 if ($in->{'binmode'} and lc $in->{'binmode'} eq 'utf8') { }
1443 0 0 unless open $write_fh, $File::Util::MODES->{'popen'}{$mode}, $clean_name
1460 0 0 unless sysopen $write_fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}
1477 0 0 unless sysopen $write_fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}, $bitmask
1493 22 51 if (-e $clean_name) { }
1495 0 22 unless open $write_fh, '<', $clean_name
1509 0 22 unless $lockstat
1513 2 20 if ($in->{'binmode'} and lc $in->{'binmode'} eq 'utf8') { }
1517 0 2 unless open $write_fh, $File::Util::MODES->{'popen'}{$mode}, $clean_name
1534 0 20 unless sysopen $write_fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}
1551 0 51 if ($in->{'binmode'} and lc $in->{'binmode'} eq 'utf8') { }
1555 0 0 unless open $write_fh, $File::Util::MODES->{'popen'}{$mode}, $clean_name
1572 0 51 unless sysopen $write_fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}, $bitmask
1588 0 51 unless $lockstat
1592 65 8 if ($mode ne 'append')
1594 0 65 unless truncate $write_fh, 0
1604 2 71 if ($in->{'binmode'}) { }
1606 2 0 if (lc $in->{'binmode'} eq 'utf8') { }
0 0 elsif ($in->{'binmode'} == 1) { }
1608 2 0 if ($File::Util::HAVE_UU) { }
1641 72 0 unless $in->{'no_lock'} or not $File::Util::USE_FLOCK
1643 0 72 unless close $write_fh
1663 0 134 unless $fh
1666 134 0 defined $file ? :
1668 0 134 unless length $file
1672 0 134 unless $File::Util::CAN_FLOCK
1682 134 1 if $fh or not scalar @policy
1696 0 128 unless $fh and ref $fh eq 'GLOB'
1700 128 0 if ($File::Util::CAN_FLOCK)
1713 314 15 !($f =~ /$File::Util::ILLEGAL_CHR/) ? :
1725 123 0 if defined $stripped
1758 0 0 if $root
1759 0 0 if $leaf
1774 0 2 unless open my $fh, '<', $file
1804 5 0 -e $f ? :
5 0 if defined $f
1823 1 0 defined $f ? :
1824 5 0 defined $f ? :
1833 5 0 -e $f ? :
5 0 if defined $f
1849 0 2 unless defined $file
1851 1 1 unless defined $escape
1853 1 1 if ($also)
1865 2 0 defined $f ? :
1877 0 26 unless defined $file and length $file
1889 0 26 if -e $file and -d $file
1903 0 26 if -e $path and not -r $path
1912 1 25 unless -e $path
1918 25 1 unless -e $file
1933 0 8 unless defined $f and -e $f
1937 2 6 if -f $f
1 7 if -T $f
1938 7 1 if -B $f
6 2 if -d $f
1939 0 8 if -l $f
0 8 if -p $f
1940 0 8 if -S $f
0 8 if -b $f
1941 0 8 if -c $f
1944 0 8 if -t $f
1947 0 8 unless scalar @ret
1960 2 3 unless scalar @rules
1975 0 6 unless exists $valid{$_}
1987 2 0 defined $f ? :
1996 0 5 unless -e $f
2009 0 5 unless -e $f
2022 0 2 unless -e $f
2043 0 6 unless length $dir
2055 1 5 if (not $opts->{'as_list'} || $opts->{'as_listref'}) { }
2071 4 1 if $opts->{'as_listref'}
2088 0 10 defined $bitmask ? :
2093 0 10 unless defined $dir and length $dir
2102 2 8 if ($opts->{'if_not_exists'}) { }
2104 0 2 if (-e $dir)
2106 0 0 if -d $dir
2120 0 8 if (-e $dir)
2122 0 0 unless -d $dir
2146 10 0 unless $dir eq '/'
2147 0 10 if $winroot
2156 0 50 unless $this->valid_filename($_)
2167 10 0 if $root
2173 10 0 if (@dirs_in_path > 1)
2176 10 40 if ($dirs_in_path[$depth - 1] eq '/') { }
2192 50 10 $i > 0 ? :
2196 0 60 if (-e $dir and not -d $dir)
2208 40 20 if -e $dir
2213 0 20 unless -w $up
2222 0 20 unless mkdir $dir, $bitmask
2245 0 3 if (defined $arg)
2247 0 0 if $arg =~ /\D/
2253 0 0 if &blessed($this) and $this->{'opts'}
2265 0 0 unless &blessed($this)
2267 0 0 if $arg
2280 0 5 if (defined $arg)
2282 0 0 if $arg =~ /\D/
2288 0 0 if &blessed($this) and $this->{'opts'}
2302 0 0 if (defined $arg)
2304 0 0 $arg ? :
2307 0 0 $arg ? :
0 0 if &blessed($this) and $this->{'opts'}
2345 1 4 exists $in->{'file'} && defined $in->{'file'} && length $in->{'file'} ? :
0 5 exists $in->{'filename'} && defined $in->{'filename'} && length $in->{'filename'} ? :
2349 0 5 unless defined $maybe_file
2350 0 5 unless defined $maybe_mode
2352 4 1 if not ref $maybe_file and $file eq ''
2357 4 1 !(ref $maybe_mode || exists $in->{'mode'}) ? :
2366 5 0 unless $file eq '/'
2367 0 5 if $winroot
2377 0 5 unless length $file
2386 0 5 if ($mode eq 'read' and not -e $raw_name)
2389 0 0 unless -e $clean_name
2405 0 5 if $try_filename =~ /(?:$File::Util::DIRSPLIT){2,}/
2422 0 8 unless $this->valid_filename($_)
2433 5 0 if $root
2436 5 0 if (not exists $in->{'use_sysopen'} || defined $in->{'use_sysopen'}) { }
2441 0 5 unless (exists $File::Util::MODES->{'popen'}{$mode} and defined $File::Util::MODES->{'popen'}{$mode})
2458 0 0 unless (exists $File::Util::MODES->{'sysopen'}{$mode} and defined $File::Util::MODES->{'sysopen'}{$mode})
2478 0 5 if (not length $root || length $path) { }
2491 0 5 if ($mode ne 'read' and not -e $root . $path)
2508 0 0 if ref $in->{'onfail'} and ref $in->{'onfail'} eq 'CODE'
2515 0 0 exists $in->{'dbitmask'} && defined $in->{'dbitmask'} ? :
2517 0 0 unless $make_dir_ok
2521 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') { }
2531 3 1 if (-e $clean_name) { }
2533 0 3 unless -w $clean_name
2545 0 1 unless -w $root . $path
2558 0 1 unless -r $root . $path
2568 0 1 unless -e $clean_name
2578 0 1 unless -r $clean_name
2601 0 0 if (exists $in->{'use_sysopen'} and defined $in->{'use_sysopen'} and ($in->{'binmode'} and lc $in->{'binmode'} eq 'utf8'))
2620 0 5 if ($in->{'no_lock'} or not $File::Util::USE_FLOCK) { }
2621 0 0 if (not exists $in->{'use_sysopen'} || defined $in->{'use_sysopen'}) { }
2628 0 0 unless open $fh, $mode, $clean_name
2644 0 0 unless sysopen $fh, $clean_name, $mode
2658 5 0 if (not exists $in->{'use_sysopen'} || defined $in->{'use_sysopen'}) { }
2663 4 1 if (-e $clean_name) { }
2665 0 4 unless open $fh, '<', $clean_name
2680 1 3 unless fileno $lockstat
2682 2 1 if ($mode ne 'read')
2692 0 2 unless open $fh, $File::Util::MODES->{'popen'}{$mode}, $clean_name
2706 0 1 unless open $fh, $File::Util::MODES->{'popen'}{$mode}, $clean_name
2713 0 1 unless $lockstat
2718 0 0 if (-e $clean_name) { }
2720 0 0 unless open $fh, '<', $clean_name
2735 0 0 unless $lockstat
2737 0 0 unless sysopen $fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}
2753 0 0 unless sysopen $fh, $clean_name, $File::Util::MODES->{'sysopen'}{$mode}, $bitmask
2769 0 0 unless $lockstat
2775 2 2 if ($in->{'binmode'})
2777 2 0 if (lc $in->{'binmode'} eq 'utf8') { }
0 0 elsif ($in->{'binmode'} == 1) { }
2779 2 0 if ($File::Util::HAVE_UU) { }
2811 0 2 unless $File::Util::USE_FLOCK
2813 0 2 unless $fh and fileno $fh
2820 2 0 if $File::Util::CAN_FLOCK
2842 0 0 unless defined $path
2844 0 0 unless defined $path
2846 0 0 unless substr $path, -1, 1 =~ /$File::Util::DIRSPLIT/
2848 0 0 $path =~ /$File::Util::DIRSPLIT/ ? :
2859 0 0 defined $dflt ? :
2863 0 0 defined $path ? :
2870 0 5 unless -e $f
2885 3 61 if defined $arg
2918 1 1 if ($name eq '_throw') { }
1 0 elsif (exists $redirect_methods->{$name}) { }
2933 0 1 $in->{'diag'} ? :
0 1 defined $in->{'diag'} && !$in->{'diag'} ? :
2935 0 1 if ($in->{'diag'} or $in->{'opts'} and ref $in->{'opts'} and ref $in->{'opts'} eq 'HASH' and $in->{'opts'}{'diag'}) { }