Branch Coverage

lib/Archive/Tar.pm
Criterion Covered Total %
branch 256 444 57.6


line true false branch
119 99 620 if @_
126 0 77 if ref $class
132 14 63 if (@_)
133 0 14 unless ($obj->read(@_))
213 48 2 if (defined $file) { }
220 0 48 unless my $handle = $self->_get_handle($file, $gzip, sub { package Archive::Tar::Constant; use warnings; use strict; shift() ? 'rb' : 'r';}->(1))
223 2 46 unless my $data = $self->_read_tar($handle, $opts)
227 5 41 wantarray ? :
232 0 93 unless defined $file
237 0 93 if (ref $file)
238 0 0 if eval { do { *$file{"IO"} } }
239 0 0 if eval { do { $file->isa("IO::Handle") } }
249 63 30 if (sub { package Archive::Tar::Constant; use warnings; use strict; $_[0] =~ /^r/ ? 1 : 0;}->($mode))
250 0 63 unless (open my $tmp, $file)
264 17 76 if (do { sub { package Archive::Tar::Constant; use warnings; $_[0] =~ /^r/ ? 1 : 0; } ->($mode) and $magic =~ /^\x42\x5A\x68[\x30-\x39]/ unless $compress eq 'bzip2' }) { }
61 15 elsif ($compress or sub { package Archive::Tar::Constant; use warnings; $_[0] =~ /^r/ ? 1 : 0; } ->($mode) or $magic =~ /^(?:\037\213|\037\235)/) { }
288 83 10 unless $compress eq "bzip2"
295 10 7 if (sub { package Archive::Tar::Constant; use warnings; $_[0] =~ /^r/ ? 1 : 0; } ->($mode)) { }
296 0 10 unless ($fh = "IO::Uncompress::Bunzip2"->new($file, "MultiStream", 1))
304 0 7 unless ($fh = "IO::Compress::Bzip2"->new($file))
321 0 61 unless ($fh->open($file, $mode))
330 0 15 unless ($fh->open($file, $mode))
346 0 81 unless my $handle = shift()
357 34 47 if $count > 0
370 81 535 if (ref $handle ne 'IO::Zlib') { }
379 77 539 unless ($read++)
381 0 77 if ($chunk =~ /$gzip/)
388 2 75 if (length $chunk != 512)
395 2 612 if length $chunk != 512
400 370 242 if $chunk eq "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0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, %extra_args))
431 0 242 if $entry->is_label
433 184 58 if (length $entry->type and $entry->is_file || $entry->is_longlink)
435 0 184 if ($entry->is_file and not $entry->validate)
440 0 0 if length $name > 100
449 0 184 if ($Archive::Tar::MAX_FILE_SIZE and $entry->size > $Archive::Tar::MAX_FILE_SIZE)
463 0 184 if ($md5) { }
22 162 elsif ($filter and not $entry->name =~ /$filter/) { }
22 140 elsif ($filter_cb and not &$filter_cb($entry)) { }
0 140 elsif ($entry->name eq 'pax_global_header' or $entry->type =~ /^(x|g)$/) { }
480 44 140 if ($skip) { }
492 44 0 if $this > $amt
493 0 44 if ($handle->read($$data, $this) < $this)
500 44 0 if $fsz < 0
501 0 44 if $skip == 5
503 0 0 if $skip == 5 and not $entry->is_longlink and not $entry->is_unknown and not $entry->is_label
510 0 140 if ($handle->read($$data, $block) < $block)
516 140 0 if defined $$data
521 51 133 if ($entry->is_longlink)
549 51 191 if ($entry->is_longlink) { }
51 140 elsif (defined $real_name) { }
558 20 171 if ($filter and not $entry->name =~ /$filter/) { }
20 151 elsif ($filter_cb and not &$filter_cb($entry)) { }
0 151 elsif ($entry->name eq 'pax_global_header' or $entry->type =~ /^(x|g)$/) { }
571 9 0 if ($extract and not $entry->is_longlink and not $entry->is_unknown and not $entry->is_label)
574 0 9 unless $self->_extract_file($entry)
578 0 151 if $entry->name eq ""
582 9 142 $extract ? :
584 21 130 if ($limit)
585 15 6 unless $entry->is_longlink or $entry->is_dir
586 15 6 unless $count
611 0 2 unless defined $full
616 1 1 if $self->_find_entry($full)
645 32 0 unless $self->{'cwd'}
648 2 30 if (@args) { }
652 1 1 if (UNIVERSAL::isa($file, 'Archive::Tar::File')) { }
664 1 0 if (exists $hashmap->{$file}) { }
680 0 32 unless (scalar @files)
687 3 108 unless ($self->_extract_file($entry))
714 0 165 unless defined $file
717 0 165 unless my $entry = $self->_find_entry($file)
725 0 288 unless my $entry = shift()
729 161 127 defined $alt ? :
734 161 127 if (defined $alt) { }
744 80 208 if ($vol or 'File::Spec'->file_name_is_absolute($dirs)) { }
748 0 0 unless (defined $alt or $Archive::Tar::INSECURE_EXTRACT_MODE)
763 111 97 ref $self && defined $self->{'cwd'} ? :
765 81 127 defined $alt ? :
770 117 10 unless (defined $alt or $Archive::Tar::INSECURE_EXTRACT_MODE)
776 1 116 if (grep {$_ eq "..";} @dirs)
796 90 11 if ref $self and $self->{'_link_cache'}{$full_path}
798 2 12 if (-l $full_path)
812 9 3 if ref $self
825 205 0 if length $cwd_file
844 0 205 unless (defined $dir)
845 0 0 if $^W
851 0 285 if (-e $dir and not -d _)
852 0 0 if $^W
856 12 273 unless (-d _)
858 1 11 if ($@)
877 18 266 if $entry->is_dir
881 0 266 if ($entry->is_unknown)
894 9 257 if (-l $full or -e _)
895 0 9 unless (unlink $full)
900 260 6 if (length $entry->type and $entry->is_file) { }
902 0 260 unless $fh->open($full, ">")
907 234 26 if ($entry->size)
914 16827 0 if (defined $written) { }
923 0 260 unless close $fh
929 0 6 unless $self->_make_special_file($entry, $full)
935 0 0 unless (-l $full or $entry->is_hardlink and !!1 and $Archive::Tar::EXTRACT_HARDLINK)
936 0 260 unless utime time, $entry->mtime - 0, $full
940 260 6 if ($Archive::Tar::CHOWN and sub { package Archive::Tar::Constant; use warnings; use strict; $^O ne 'MSWin32' if $> == 0 and $^O ne 'MacOS';}->() and not -l $full and not $entry->is_hardlink && 1 && $Archive::Tar::EXTRACT_HARDLINK)
941 0 260 unless CORE::chown $entry->uid, $entry->gid, $full
947 260 6 if ($Archive::Tar::CHMOD and not -l $full and not $entry->is_hardlink && 1 && $Archive::Tar::EXTRACT_HARDLINK)
949 0 260 unless ($Archive::Tar::SAME_PERMISSIONS)
952 0 260 unless CORE::chmod $mode, $full
961 0 6 unless my $entry = shift()
962 0 6 unless defined $file
966 6 0 if ($entry->is_symlink) { }
0 0 elsif ($entry->is_hardlink) { }
0 0 elsif ($entry->is_fifo) { }
0 0 elsif ($entry->is_blockdev or $entry->is_chardev) { }
0 0 elsif ($entry->is_socket) { }
967 2 4 unless ($Archive::Tar::INSECURE_EXTRACT_MODE)
969 0 2 if ("File::Spec"->file_name_is_absolute($linkname))
974 0 2 if (grep {$_ eq "..";} "File::Spec"->splitdir($linkname))
982 0 6 unless symlink $entry->linkname, $file
989 0 6 if $fail
993 0 0 unless ($Archive::Tar::INSECURE_EXTRACT_MODE)
995 0 0 if ("File::Spec"->file_name_is_absolute($linkname))
1002 0 0 if (grep {$_ eq "..";} "File::Spec"->splitdir($linkname))
1011 0 0 if ($Archive::Tar::EXTRACT_HARDLINK) { }
1012 0 0 unless link $entry->linkname, $file
1015 0 0 unless $self->_extract_special_file_as_plain_file($entry, $file)
1019 0 0 if $fail
1023 0 0 if system "mknod", $file, "p"
1027 0 0 $entry->is_blockdev ? :
1029 0 0 if system "mknod", $file, $mode, $entry->devmajor, $entry->devminor
1040 0 6 $err ? :
1047 0 0 unless my $entry = shift()
1048 0 0 unless defined $file
1054 0 0 unless ($orig)
1063 0 0 unless $self->_extract_file($clone, $file)
1092 0 38 unless ($self->_data)
1093 0 0 unless $self->read
1096 38 0 if (@$aref == 0 or @$aref == 1 and $aref->[0] eq 'name') { }
1118 0 218 unless (defined $file)
1124 16 202 if UNIVERSAL::isa($file, "Archive::Tar::File")
1127 202 0 if ($self->_data)
1130 199 311 if $path eq $file
1134 3 0 unless ($Archive::Tar::RESOLVE_SYMLINK =~ /none/)
1135 0 3 if (my $link_entry = shift())
1137 0 0 if $self->_data
1142 0 0 if ($Archive::Tar::RESOLVE_SYMLINK =~ /speed/ and @$iterargs == 3)
1148 0 0 if ($archive->_data)
1158 0 0 if ($e->full_path eq $file)
1185 105 4 unless @_
1203 0 11 unless my $entry = $self->_find_entry(shift())
1216 0 1 unless my $entry = $self->_find_entry(shift())
1234 0 2 unless defined $file
1235 0 2 unless defined $new
1237 0 2 unless my $entry = $self->_find_entry($file)
1252 0 1 unless defined $file
1253 0 1 unless defined $mode and $mode =~ /^[0-7]{1,4}$/
1256 0 1 unless my $entry = $self->_find_entry($file)
1271 0 2 unless defined $file
1272 0 2 unless defined $uname
1276 0 2 unless my $entry = $self->_find_entry($file)
1310 0 2 unless my $self = shift()
1358 3 30 unless defined $file
1360 33 0 unless defined $ext_prefix
1367 0 0 $Archive::Tar::HAS_IO_STRING ? :
3 0 $Archive::Tar::HAS_PERLIO ? :
30 3 length $file ? :
1388 4 70 if ($Archive::Tar::DO_NOT_USE_PREFIX) { }
1392 0 4 length $ext_prefix ? :
1407 0 70 if length $ext_prefix
1421 9 65 if ($make_longlink)
1428 0 9 unless ($longlink)
1452 0 83 if $link_ok
1456 0 83 unless ($header)
1462 0 83 unless (print $handle $header)
1468 70 13 if ($link_ok or $data_ok)
1469 0 70 unless (print $handle $clone->data)
1476 70 0 if $clone->size % 512
1483 0 33 unless print $handle "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
1489 3 0 $Archive::Tar::HAS_PERLIO ? :
30 3 length $file ? :
1492 33 0 if ($file ne $handle)
1493 0 33 unless (close $handle)
1504 0 83 unless my $entry = shift()
1505 83 0 unless defined $ext_prefix
1509 0 83 unless defined $prefix
1520 0 83 if length $ext_prefix
1525 4 79 if length $prefix >= 155
1527 0 83 $Archive::Tar::ZERO_PAD_NUMBERS ? :
1544 0 83 $no_prefix ? :
1550 0 83 $Archive::Tar::ZERO_PAD_NUMBERS ? :
1580 0 25 unless my(@files) = @_
1588 7 22 if (UNIVERSAL::isa($file, "Archive::Tar::File"))
1594 0 22 if (utf8::is_utf8($file))
1599 0 22 unless (-e $file or -l $file)
1605 0 22 unless ($obj)
1676 1 13 unless ($obj)
1706 15 0 if (ref $self)
1713 6 9 if ($Archive::Tar::WARN)
1714 0 6 $Archive::Tar::DEBUG ? :
1722 20 2 if (ref $self) { }
1723 0 20 shift() ? :
1725 0 2 shift() ? :
1814 0 9 unless defined $file
1818 0 9 unless (@files)
1856 0 15 unless defined $filename
1861 0 15 unless my $handle = $class->_get_handle($filename, $compressed, sub { package Archive::Tar::Constant; use warnings; use strict; shift() ? 'rb' : 'r';}->(1))
1870 2 33 if @data
1871 0 33 unless $handle
1875 33 0 if ref $tarfile and ref $tarfile eq "ARRAY"
1876 33 0 unless ($Archive::Tar::RESOLVE_SYMLINK =~ /none/)
1879 1 19 if ($_->linkname)
1887 18 15 if @data
1891 0 15 if (@$CONSTRUCT_ARGS == 4)
1921 0 3 unless defined $file
1925 0 3 unless $tar
1946 0 9 unless defined $file
1949 0 9 unless my $tar = $class->new
2031 0 0 if (@trg and $trg[0] eq "")
2037 0 0 if $part eq "."
2038 0 0 if ($part eq '..') { }
2048 0 0 if $Archive::Tar::DEBUG