Branch Coverage

blib/lib/File/Unpack.pm
Criterion Covered Total %
branch 123 712 17.2


line true false branch
110 7 0 unless $ENV{'FILE_UNPACK_HELPER_DIR'}
175 0 0 if defined $$self{'_locate_tar'}
180 0 0 -f '/bin/tar' ? :
183 0 0 unless $self->run([@tar, '--force-local', '--help'], {'out_err', '/dev/null'})
185 0 0 unless $self->run([@tar, '--no-unquote', '--help'], {'out_err', '/dev/null'})
195 0 0 if defined $$self{'_locate_cpio_i'}
198 0 0 unless run(['/usr/bin/cpio', '-idmu', '--usage'], {'out_err', '/dev/null'})
200 0 0 unless run([@cpio_i, '--sparse', '--usage'], {'out_err', '/dev/null'})
202 0 0 unless run([@cpio_i, '--no-absolute-filenames', '--usage'], {'out_err', '/dev/null'})
204 0 0 unless run([@cpio_i, '--force-local', '--usage'], {'out_err', '/dev/null'})
363 0 3 unless @_
382 0 12 unless my $re = $$self{'exclude'}{'re'}
385 0 12 unless $dir =~ m[/$]
388 10 2 if $file =~ /$re/
395 3 0 $#_ ? :
400 0 3 unless ref $opt{'add'}
401 3 0 unless ref $opt{'del'}
403 3 0 if defined $opt{'vcs'} and $opt{'vcs'}
404 0 3 if defined $opt{'vcs'} and not $opt{'vcs'}
409 25 0 if defined $a
414 0 3 if defined $a
420 0 3 if defined $opt{'empty'}
424 0 9 if defined $opt{$o}
427 0 3 if defined $opt{'follow_file_symlinks'}
430 1 2 $opt{'re'} ? :
454 4 0 if (my $fp = $$self{'lfp'})
457 0 4 unless $fp->write($text)
462 0 4 if $r and $r != length $text
471 0 0 unless ($$self{'log_fullpath'})
474 0 0 unless ($file =~ s[^\Q$$self{'destdir'}\E/][])
477 0 0 if ($$self{'input'})
479 0 0 if ($file =~ s[^\Q$$self{'input'}\E/][./input/./])
481 0 0 if ref $hash eq 'HASH'
492 0 0 unless defined $suff
495 0 0 if (my $fp = $$self{'lfp'})
497 0 0 if ($$self{'log_type'} eq 'plain') { }
500 0 0 if defined $$hash{'mime'}
502 0 0 if $$hash{'unpacked'}
508 0 0 unless $$self{'lfp_printed'}
514 0 0 if $$self{'logf_continuation'}++
515 0 0 if $str =~ /(?:\n|\r)/
544 0 0 unless defined $needed_b
545 0 0 unless defined $needed_i
546 0 0 unless defined $needed_p
550 0 0 unless open $DIR, '<', $$self{'destdir'} or opendir $DIR, $$self{'destdir'}
553 0 0 unless defined $fd
563 0 0 if $free_b >= $needed_b and $free_i >= $needed_i and 100 - $perc > $needed_p
567 0 0 unless $$self{'fs_warn'}
569 0 0 if $w
578 0 7 ref $_[0] eq 'HASH' ? :
580 4 3 unless defined $obj{'verbose'}
585 7 0 unless defined $obj{'maxfilesize'}
594 7 0 unless defined $obj{'dot_dot_safeguard'}
606 4 3 if $obj{'verbose'} and not $>
608 3 4 if (ref $obj{'logfile'} eq 'SCALAR' or not ref $obj{'logfile'}) { }
610 0 3 unless open $obj{'lfp'}, '>', $obj{'logfile'}
623 0 7 if ($obj{'world_readable'})
629 7 0 if ($obj{'maxfilesize'})
636 7 0 if ($have[0] == RLIM_INFINITY() or $have[0] > $obj{'maxfilesize'})
639 0 7 unless &BSD::Resource::setrlimit(RLIMIT_FSIZE(), $obj{'maxfilesize'}, RLIM_INFINITY()) or &BSD::Resource::setrlimit(RLIMIT_FSIZE(), $obj{'maxfilesize'}, $obj{'maxfilesize'})
644 0 7 if ($@)
650 7 0 unless defined $obj{'minfree'}{'factor'}
651 7 0 unless defined $obj{'minfree'}{'bytes'}
652 7 0 unless defined $obj{'minfree'}{'percent'}
655 7 0 unless defined $obj{'exclude'}{'empty_dir'}
656 7 0 unless defined $obj{'exclude'}{'empty_file'}
664 7 0 unless exists $obj{'helper_dir'}
665 0 7 if defined $obj{'helper_dir'} and -d $obj{'helper_dir'}
667 7 0 unless ($ENV{'PERL5LIB'})
677 7 49 if $i =~ /$pat/
680 7 0 if @add
695 2 5 if ($$self{'input'} || ($$self{'lfp_printed'} || 0) || ($$self{'recursion_level'} || 0) and $$self{'lfp'})
699 0 2 if ($$self{'log_type'} eq 'plain') { }
705 0 2 unless $$self{'lfp_printed'}
713 0 2 if $$self{'error'}
714 0 2 if ($$self{'log_type'} eq 'plain') { }
722 2 0 if $$self{'lfp'} ne $$self{'logfile'}
726 0 7 if ($$self{'configdir'})
855 2 13 unless defined $destdir
857 15 0 if $destdir =~ /^(.*)$/s
859 0 15 if (($$self{'recursion_level'} || 0) > $RECURSION_LIMIT)
866 15 0 unless ($archive =~ m[^/] and $archive =~ m[^\Q$$self{'destdir'}\E/])
874 0 15 if ($$self{'follow_file_symlinks'} and $archive =~ m[^(.*)/(.*?)$]) { }
879 0 0 if -e $a_path
884 15 0 if -e $archive
889 2 13 if ($$self{'recursion_level'}++ == 0)
891 0 2 if $$self{'verbose'} > 1
901 2 0 if $archive =~ m[^(.*)/([^/]*)$]
903 0 2 if ($$self{'log_type'} eq 'plain') { }
911 0 2 if keys %{$$self{'log_params'};}
918 0 15 unless (-e $archive)
926 0 15 unless ($$self{'input_dir'})
933 15 0 if $archive =~ m[^(.*/)([^/]*)$]
937 15 0 unless ($subdir =~ s[^\Q$$self{'destdir'}\E/+][])
940 0 15 unless $subdir =~ s[^\Q$$self{'input_dir'}\E/+][]
944 0 15 if $$self{'verbose'} > 1
948 0 15 if ($$self{'progress_tstamp'} + 10 < $start_time)
954 3 12 if (-d $archive) { }
12 0 elsif (-f $archive) { }
957 3 0 if (opendir DIR, $archive) { }
959 47 3 if $_ ne '.'
961 0 3 if $$self{'verbose'} > 1
964 10 3 if ($$self{'exclude'}{'re'} and $f =~ /$$self{'exclude'}{'re'}/)
971 1 12 if -d $new_in
973 0 13 $$self{'inside_archives'} ? :
974 0 13 if ($symlink_to_skip and $$self{'follow_file_symlinks'} > $dangeous_symlink)
976 0 0 if -f $new_in
981 0 13 if ($symlink_to_skip) { }
13 0 elsif (-f $new_in or -d _) { }
984 0 0 if $$self{'verbose'} > 1
993 0 0 if $$self{'verbose'} > 1
1006 2 10 if ($self->_not_excluded($subdir, $in_file) and not defined $$self{'done'}{$archive})
1014 0 0 if ($more)
1017 0 0 if $$more{'missing'}
1020 0 0 if ($$m[0] eq 'text/plain' or not $h) { }
1023 0 0 if (not $archive =~ m[^\Q$$self{'destdir'}\E/]) { }
1025 0 0 unless $$self{'no_op'}
1027 0 0 if "$destdir/$in_file" =~ /^(.*)$/s
1029 0 0 if (-e "$destdir_in_file")
1031 0 0 if $$self{'verbose'}
1033 0 0 if "$destdir/$in_file" =~ /^(.*)$/s
1034 0 0 if $$self{'verbose'}
1036 0 0 unless File::Copy::copy($archive, $destdir_in_file)
1048 0 0 if ($$self{'archive_name_as_dir'})
1050 0 0 if $$self{'verbose'}
1052 0 0 if $$self{'verbose'}
1054 0 0 unless $$self{'no_op'}
1055 0 0 unless exists $$self{'configdir'}
1063 0 0 unless ($$h{'suffix_re'} and $new_name =~ s/[\._-]$$h{'suffix_re'}(?:\._\d*)?$//i)
1087 0 0 unless (ref $unpacked or -e $unpacked)
1093 0 0 if $$self{'no_op'}
1094 0 0 if (ref $unpacked) { }
0 0 elsif (readlink $unpacked or '' eq $archive) { }
1099 0 0 if defined $$unpacked{'stderr'}
1108 0 0 if $$self{'archive_name_as_dir'}
1115 0 0 if $diag
1118 0 0 if ($archive =~ /^\Q$$self{'destdir'}\E/) { }
1128 0 0 if (File::Copy::copy($archive, $unpacked)) { }
1147 0 0 if ($archive =~ /^\Q$$self{'destdir'}\E/)
1159 0 0 unless -d $newdestdir
1160 0 0 unless $newdestdir =~ m[^\Q$$self{'destdir'}\E/]
1161 0 0 if ($$self{'one_shot'}) { }
1184 0 10 if (--$$self{'recursion_level'} == 0)
1186 0 0 if ($$self{'log_type'} eq 'plain') { }
1196 0 0 if $$self{'error'}
1201 0 0 if $$self{'skipped'}
1202 0 0 if $$self{'error'}
1203 0 0 if $$self{'helper_errors'}
1204 0 0 if @missing_unpacker
1211 0 0 if ($$self{'lfp'} ne $$self{'logfile'})
1213 0 0 unless close $$self{'lfp'}
1220 0 10 $$self{'error'} ? :
1228 5 0 if $file =~ /^(.*)$/m
1232 5 0 if chmod $perm | $m, $file
1264 0 0 if ref $_[0] ne 'ARRAY'
1267 0 0 if ref $cmd[-1] eq 'HASH'
1294 0 0 if (ref $c)
1299 0 0 if $$opt{'init'}
1303 0 0 if $c =~ /^0?
1304 0 0 if $c =~ /^1?>/
1305 0 0 if $c =~ /^(?:2>|>&$)/
1306 0 0 if ($c eq '|')
1308 0 0 unless $has_i_redir
1310 0 0 unless $has_e_redir
1316 0 0 unless $has_i_redir
1317 0 0 unless $has_o_redir
1318 0 0 unless $has_e_redir
1323 0 0 if $$opt{'every'}
1324 0 0 if $t
1326 0 0 if $run[0][0] =~ /^(.*)$/s
1327 0 0 if $$opt{'debug'}
1329 0 0 wantarray ? :
0 0 unless $h
1336 0 0 if ($t and $t->is_expired)
1347 0 0 if $$t{'has_fired'}
1349 0 0 wantarray ? :
1365 413 0 if (@a and defined $a[0])
1367 35 378 if $a[0] eq \&_locate_tar
1368 14 399 if $a[0] eq \&_locate_cpio_i
1371 49 364 if ($sub)
1382 0 189 if ref $a[0] eq 'HASH'
1386 217 196 ref $a ? :
1389 98 91 unless $#a
1417 0 0 if $argv[$i] =~ /^(.*)$/s
1422 0 0 if $dot_dot_safeguard < 2
1426 0 0 unless ($$self{'no_op'})
1444 0 0 unless $$args{'src'} =~ m[^/]
1449 0 0 if (ref $a) { }
1464 0 0 if ($$self{'no_op'})
1470 0 0 if $$self{'verbose'} > 1
1472 0 0 unless my $cwd = getcwd()
1473 0 0 if $cwd =~ /^(.*)$/s
1474 0 0 unless chdir $jail
1475 0 0 if $$self{'jail_chmod0'}
1487 0 0 if $$self{'verbose'}
0 0 unless length $run_error
1492 0 0 if ($_[1]{'finished'}) { }
0 0 elsif (my $p = _children_fuser($_[1]{'watch'}, POSIX::getpid())) { }
1494 0 0 if $$self{'verbose'}
1508 0 0 if ($diff > $largest_diff)
1516 0 0 if $largest_diff <= 0
1520 0 0 if $$self{'verbose'}
1525 0 0 if $$self{'verbose'}
1529 0 0 $$self{'verbose'} > 2 ? :
1534 0 0 if $$self{'jail_chmod0'}
1535 0 0 unless chdir $cwd
1541 0 0 if $nonzero[0] and $$self{'verbose'}
1548 0 0 if ($nonzero[0])
1566 0 0 unless opendir DIR, $jail_base
1567 0 0 if $_ ne '.'
1570 0 0 if defined $found[0] and $found[0] =~ /^(.*)$/s
1571 0 0 if $$self{'verbose'} > 2
1572 0 0 unless (@found)
1576 0 0 if $$args{'src'} =~ m[/([^/]+)$]
1577 0 0 if $$self{'verbose'}
1580 0 0 if scalar @found != 1
1581 0 0 if $i == $dot_dot_safeguard
1582 0 0 unless -d $jail_base . '/' . $found0
1585 0 0 unless rename $jail_base, $jail_tmp
1586 0 0 unless rename $jail_tmp . '/' . $found0, $jail_base
1587 0 0 unless rmdir $jail_tmp
1594 0 0 if $$self{'verbose'} > 1 and defined $wanted_name and not $wanted_name =~ /^\Q$$args{'destfile'}\E/
1597 0 0 unless defined $wanted_name
1599 0 0 if defined $wanted_name
1601 0 0 if (defined $wanted_name and not -e $wanted_path)
1603 0 0 if (-d $jail_base) { }
1608 0 0 if $_ ne '.'
1611 0 0 if defined $found[0] and $found[0] =~ /^(.*)$/s
1613 0 0 if ($#found == 0 and $found0 eq $wanted_name) { }
1615 0 0 unless rename "$jail_base/$found0", $wanted_path
1620 0 0 unless rename $jail_base, $wanted_path
1625 0 0 unless rename $jail_base, $wanted_path
1631 0 0 if (-f $unpacked and not -l $unpacked)
1633 0 0 if (not -s $unpacked) { }
0 0 elsif (-s $unpacked eq (my $s = -s $$args{'src'})) { }
1635 0 0 if $$self{'verbose'}
1641 0 0 if $$self{'verbose'}
1644 0 0 if (File::Compare::cmp($$args{'src'}, $unpacked) == 0)
1646 0 0 if $$self{'verbose'}
1654 0 0 if defined $run_error
1663 0 0 if (-e $wanted_path)
1672 0 0 unless (-e $test_path . $i)
1679 0 0 if -e $wanted_path
1690 0 0 unless opendir DIR, '/proc'
1697 0 0 if (open IN, '<', "/proc/$p/stat")
1702 0 0 if ($text =~ /\((.*)\)\s+(\w)\s+(\d+)/s)
1712 0 0 if ($ppid > 1)
1722 0 0 if ($pid == $ppid or $pid == 1)
1727 0 0 unless $p{$pid}
1730 0 0 unless $family
1739 0 0 if (opendir DIR, "/proc/$p/fd")
1746 0 0 unless defined $r
1748 0 0 if ($r eq $file)
1767 0 0 if (open IN, "/proc/$pid/fdinfo/$fd")
1772 0 0 if $line =~ /^(\w+):\s+(.*)\b/
1796 0 0 $group eq '' ? :
1800 0 0 if $k eq 'recursion_level'
1801 0 0 if ref $val
1802 0 0 $group eq '' ? :
1897 0 189 unless @args
1898 0 189 unless ref $args[0]
1899 0 189 unless $#{$args[0];} or defined $args[1]
1904 0 189 unless ($name =~ m[[/=]])
1906 0 0 if $$self{'verbose'}
1944 5 22 if length $$m{'pat'} > $width
1962 0 0 if (opendir DIR, $d) { }
1975 0 0 unless ($h =~ m[[/=]])
1978 0 0 unless defined $h{$h2}
1999 0 0 if ($1 eq '=') { }
2036 0 0 if ref $mimetype eq 'ARRAY'
2038 0 0 if defined $$self{'mime_orcish'}{$mimetype} and -f $$self{'mime_orcish'}{$mimetype}{'argvv'}[0][0]
2045 0 0 if ($mimetype =~ /$$h{'pat'}/)
2048 0 0 unless (-f $$h{'argvv'}[0][0])
2054 0 0 wantarray ? :
2057 0 0 wantarray ? :
2079 0 0 if (ref $$h{'argvv'} eq 'CODE')
2092 0 0 if (ref $$h{'argvv'}[$idx] eq 'CODE')
2104 0 0 unless ref $$h{'argvv'}[$idx] eq 'ARRAY'
2108 0 0 if (ref $$h{'argvv'}[$idx][$idx1] eq 'CODE')
2119 0 0 if $update_fmt_p
2161 0 14 if $text =~ /([\d\.]+)k/i
2162 7 7 if $text =~ /([\d\.]+)m/i
2163 7 0 if $text =~ /([\d\.]+)g/i
2164 0 0 if $text =~ /([\d\.]+)t/i
2171 0 0 unless defined $dec_places
2175 0 0 if ($number < 0)
2179 0 0 if ($number > $div * 1024)
2182 0 0 if ($number > $div * 1024)
2185 0 0 if ($number > $div * 1024)
2188 0 0 if ($number > $div * 1024)
2207 0 21 if defined $opt{$i}
2212 7 0 if ref $opt{'warning'}
2276 0 4 if not $#in and ref $in[0] eq 'HASH'
2277 3 0 unless $#in or ref $in[0]
2278 4 0 if $#in > 0
2282 0 0 unless (defined $in{'buf'})
2285 0 0 unless ($fd)
2287 0 0 unless open $fd, '<', $in{'file'}
2296 0 0 unless defined $len
2297 0 0 if $len < 0
2298 0 0 if $len == 0
2301 0 0 unless $in{'fd'}
2308 0 0 if ($mime1 =~ /, corrupt: / or $mime1 =~ m[^application/octet-stream\b])
2312 0 0 if $$self{'verbose'} > 2
2313 0 0 if (defined $in{'file'} and -f $in{'file'})
2315 0 0 if $$self{'verbose'} > 1
2319 0 0 if $$self{'verbose'} > 1
2320 0 0 unless defined $in{'file'}
2322 0 0 if $mime1 =~ /^cannot open/
2325 0 0 if $mime1 =~ /^(.*?);\s*(.*)$/ or $mime1 =~ /^(.*?)\s+(.*)$/
2327 0 0 if defined $enc
2332 0 0 if ($mime1 =~ m[^application/xml])
2340 0 0 if ($mime1 =~ m[^text/x-(?:pascal|fortran)$]) { }
0 0 elsif ($mime1 eq 'text/plain' and $r[2] =~ /(?:PostScript|font)/i or $mime1 eq 'application/postscript') { }
2353 0 0 if ($mime2 ||= eval { do { open my $fd, '<', \$in{'buf'}; File::MimeInfo::Magic::magic($fd) } })
2355 0 0 if $mime2 =~ m[/(\S+)]
2371 0 0 if ($mime2 and $mime2 =~ m[^(.*)/(.*)$])
2374 0 0 if $r[2] =~ /\btext\b/i
2379 0 0 if ($r[0] eq 'text/plain' or $r[0] eq 'application/octet-stream')
2384 0 0 if $r[2] eq 'uuencoded or xxencoded text'
2389 0 0 if $r[2] =~ m[^a (\S*/)?([^/\s]+) .*script text$]i
2390 0 0 if ($r[2] =~ /\bimage\b/)
2396 0 0 if $mime2 and $mime2 =~ m[^image/]
2400 0 0 if ($r[0] eq 'application/octet-stream')
2412 0 0 if -T $in{'file'}
2414 0 0 if $mime2
2417 0 0 if ($r[0] eq 'application/octet-stream')
2419 0 0 if ($r[2] =~ /\bcpio\s+archive\b/i)
2426 0 0 if ($r[0] eq 'application/octet-stream')
2428 0 0 if ($r[2] =~ /\bxar\s+archive\b/i)
2437 0 0 if ($r[0] eq 'application/octet-stream')
2458 0 0 if (10 < length $in{'buf'})
2464 0 0 if ($lz)
2467 0 0 if ($stat == 'LZMA_OK' || $stat == 'LZMA_STREAM_END' and length $uncomp_buf > length $saved_input)
2481 0 0 if ($r[0] =~ m[^application/(?:x-)?gzip$])
2484 0 0 if ($gz)
2495 0 0 if ($r[0] =~ m[^application/(?:x-)?bzip2$] and not $in{'recursion'})
2499 0 0 if ($bz)
2502 0 0 unless $in{'file'} eq '-'
2508 0 0 if length $in{'buf'}
2509 0 0 if length $stat
2510 0 0 unless read $IN, $in{'buf'}, 10240, length $in{'buf'}
2534 0 0 if ($a eq 'application') { }
2550 0 0 if ($r[0] eq 'application/unknown+zip' and $r[2] =~ /\btext\b/i)
2555 0 0 if ($mime2 ||= eval { do { open my $fd, '<', \$in{'buf'}; File::MimeInfo::Magic::magic($fd) } })
2557 0 0 unless $mime2 =~ /\+zip/i
2558 0 0 if $mime2 =~ m[^application/]
2561 0 0 if $r[0] =~ m[^application/vnd\.oasis\.opendocument\.text$]
2563 0 0 if ($r[0] eq 'text/plain' and $in{'file'} =~ /\.(mm|b64|base64)$/i)
2569 0 0 if ($r[0] eq 'application/octet-stream' and $in{'file'} =~ /\.(lzma|zx|lz)$/i)
2575 0 0 if ($r[0] =~ m[^application/x-(ms-dos-|)executable$])
2577 0 0 if (-x '/usr/bin/upx')
2581 0 0 if -l $in{'file'}
2582 0 0 unless run(['/usr/bin/upx', '-q', '-q', '-t', $in_file])
2586 0 0 if ref $in{'uncomp'} eq 'SCALAR'
2587 0 0 if $mime1 ne $r[0] or $mime2 and $mime2 ne $mime1