Branch Coverage

lib/Archive/Tar.pm
Criterion Covered Total %
branch 251 430 58.3


line true false branch
118 99 620 if @_
125 0 77 if ref $class
131 14 63 if (@_)
132 0 14 unless ($obj->read(@_))
212 48 2 if (defined $file) { }
219 0 48 unless my $handle = $self->_get_handle($file, $gzip, sub { package Archive::Tar::Constant; use warnings; use strict; shift() ? 'rb' : 'r';}->(1))
222 2 46 unless my $data = $self->_read_tar($handle, $opts)
226 5 41 wantarray ? :
231 0 93 unless defined $file
236 0 93 if (ref $file)
237 0 0 if eval { do { *$file{"IO"} } }
238 0 0 if eval { do { $file->isa("IO::Handle") } }
248 63 30 if (sub { package Archive::Tar::Constant; use warnings; use strict; $_[0] =~ /^r/ ? 1 : 0;}->($mode))
249 0 63 unless (open my $tmp, $file)
263 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)/) { }
287 83 10 unless $compress eq "bzip2"
294 10 7 if (sub { package Archive::Tar::Constant; use warnings; $_[0] =~ /^r/ ? 1 : 0; } ->($mode)) { }
295 0 10 unless ($fh = "IO::Uncompress::Bunzip2"->new($file, "MultiStream", 1))
303 0 7 unless ($fh = "IO::Compress::Bzip2"->new($file))
320 0 61 unless ($fh->open($file, $mode))
329 0 15 unless ($fh->open($file, $mode))
345 0 81 unless my $handle = shift()
356 34 47 if $count > 0
369 81 535 if (ref $handle ne 'IO::Zlib') { }
378 77 539 unless ($read++)
380 0 77 if ($chunk =~ /$gzip/)
387 2 75 if (length $chunk != 512)
394 2 612 if length $chunk != 512
399 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))
430 0 242 if $entry->is_label
432 184 58 if (length $entry->type and $entry->is_file || $entry->is_longlink)
434 0 184 if ($entry->is_file and not $entry->validate)
439 0 0 if length $name > 100
454 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)$/) { }
471 44 140 if ($skip) { }
483 44 0 if $this > $amt
484 0 44 if ($handle->read($$data, $this) < $this)
491 44 0 if $fsz < 0
492 0 44 if $skip == 5
494 0 0 if $skip == 5 and not $entry->is_longlink and not $entry->is_unknown and not $entry->is_label
501 0 140 if ($handle->read($$data, $block) < $block)
507 140 0 if defined $$data
512 51 133 if ($entry->is_longlink)
540 51 191 if ($entry->is_longlink) { }
51 140 elsif (defined $real_name) { }
549 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)$/) { }
562 9 0 if ($extract and not $entry->is_longlink and not $entry->is_unknown and not $entry->is_label)
565 0 9 unless $self->_extract_file($entry)
569 0 151 if $entry->name eq ""
573 9 142 $extract ? :
575 21 130 if ($limit)
576 15 6 unless $entry->is_longlink or $entry->is_dir
577 15 6 unless $count
602 0 2 unless defined $full
607 1 1 if $self->_find_entry($full)
636 32 0 unless $self->{'cwd'}
639 2 30 if (@args) { }
643 1 1 if (UNIVERSAL::isa($file, 'Archive::Tar::File')) { }
655 1 0 if (exists $hashmap->{$file}) { }
671 0 32 unless (scalar @files)
678 3 108 unless ($self->_extract_file($entry))
705 0 165 unless defined $file
708 0 165 unless my $entry = $self->_find_entry($file)
716 0 288 unless my $entry = shift()
720 161 127 defined $alt ? :
725 161 127 if (defined $alt) { }
735 80 208 if ($vol or 'File::Spec'->file_name_is_absolute($dirs)) { }
739 0 0 unless (defined $alt or $Archive::Tar::INSECURE_EXTRACT_MODE)
754 111 97 ref $self && defined $self->{'cwd'} ? :
756 81 127 defined $alt ? :
761 121 6 unless (defined $alt or $Archive::Tar::INSECURE_EXTRACT_MODE)
767 1 120 if (grep {$_ eq "..";} @dirs)
787 94 15 if ref $self and $self->{'_link_cache'}{$full_path}
789 2 24 if (-l $full_path)
803 13 11 if ref $self
816 205 0 if length $cwd_file
835 0 205 unless (defined $dir)
836 0 0 if $^W
842 0 285 if (-e $dir and not -d _)
843 0 0 if $^W
847 12 273 unless (-d _)
849 1 11 if ($@)
868 18 266 if $entry->is_dir
872 0 266 if ($entry->is_unknown)
885 9 257 if (-l $full or -e _)
886 0 9 unless (unlink $full)
891 260 6 if (length $entry->type and $entry->is_file) { }
893 0 260 unless $fh->open($full, ">")
898 234 26 if ($entry->size)
905 16827 0 if (defined $written) { }
914 0 260 unless close $fh
920 0 6 unless $self->_make_special_file($entry, $full)
926 0 0 unless (-l $full or $entry->is_hardlink and !!1 and $Archive::Tar::EXTRACT_HARDLINK)
927 0 260 unless utime time, $entry->mtime - 0, $full
931 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)
932 0 260 unless CORE::chown $entry->uid, $entry->gid, $full
938 260 6 if ($Archive::Tar::CHMOD and not -l $full and not $entry->is_hardlink && 1 && $Archive::Tar::EXTRACT_HARDLINK)
940 0 260 unless ($Archive::Tar::SAME_PERMISSIONS)
943 0 260 unless CORE::chmod $mode, $full
952 0 6 unless my $entry = shift()
953 0 6 unless defined $file
957 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) { }
960 0 6 unless symlink $entry->linkname, $file
967 0 6 if $fail
972 0 0 if ($Archive::Tar::EXTRACT_HARDLINK) { }
973 0 0 unless link $entry->linkname, $file
976 0 0 unless $self->_extract_special_file_as_plain_file($entry, $file)
980 0 0 if $fail
984 0 0 if system "mknod", $file, "p"
988 0 0 $entry->is_blockdev ? :
990 0 0 if system "mknod", $file, $mode, $entry->devmajor, $entry->devminor
1001 0 6 $err ? :
1008 0 0 unless my $entry = shift()
1009 0 0 unless defined $file
1015 0 0 unless ($orig)
1024 0 0 unless $self->_extract_file($clone, $file)
1053 0 38 unless ($self->_data)
1054 0 0 unless $self->read
1057 38 0 if (@$aref == 0 or @$aref == 1 and $aref->[0] eq 'name') { }
1079 0 218 unless (defined $file)
1085 16 202 if UNIVERSAL::isa($file, "Archive::Tar::File")
1088 202 0 if ($self->_data)
1091 199 311 if $path eq $file
1095 3 0 unless ($Archive::Tar::RESOLVE_SYMLINK =~ /none/)
1096 0 3 if (my $link_entry = shift())
1098 0 0 if $self->_data
1103 0 0 if ($Archive::Tar::RESOLVE_SYMLINK =~ /speed/ and @$iterargs == 3)
1109 0 0 if ($archive->_data)
1119 0 0 if ($e->full_path eq $file)
1146 105 4 unless @_
1164 0 11 unless my $entry = $self->_find_entry(shift())
1177 0 1 unless my $entry = $self->_find_entry(shift())
1195 0 2 unless defined $file
1196 0 2 unless defined $new
1198 0 2 unless my $entry = $self->_find_entry($file)
1213 0 1 unless defined $file
1214 0 1 unless defined $mode and $mode =~ /^[0-7]{1,4}$/
1217 0 1 unless my $entry = $self->_find_entry($file)
1232 0 2 unless defined $file
1233 0 2 unless defined $uname
1237 0 2 unless my $entry = $self->_find_entry($file)
1271 0 2 unless my $self = shift()
1319 3 30 unless defined $file
1321 33 0 unless defined $ext_prefix
1328 0 0 $Archive::Tar::HAS_IO_STRING ? :
3 0 $Archive::Tar::HAS_PERLIO ? :
30 3 length $file ? :
1349 4 70 if ($Archive::Tar::DO_NOT_USE_PREFIX) { }
1353 0 4 length $ext_prefix ? :
1368 0 70 if length $ext_prefix
1382 9 65 if ($make_longlink)
1389 0 9 unless ($longlink)
1413 0 83 if $link_ok
1417 0 83 unless ($header)
1423 0 83 unless (print $handle $header)
1429 70 13 if ($link_ok or $data_ok)
1430 0 70 unless (print $handle $clone->data)
1437 70 0 if $clone->size % 512
1444 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\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\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"
1450 3 0 $Archive::Tar::HAS_PERLIO ? :
30 3 length $file ? :
1453 33 0 if ($file ne $handle)
1454 0 33 unless (close $handle)
1465 0 83 unless my $entry = shift()
1466 83 0 unless defined $ext_prefix
1470 0 83 unless defined $prefix
1481 0 83 if length $ext_prefix
1486 4 79 if length $prefix >= 155
1488 0 83 $Archive::Tar::ZERO_PAD_NUMBERS ? :
1505 0 83 $no_prefix ? :
1511 0 83 $Archive::Tar::ZERO_PAD_NUMBERS ? :
1541 0 25 unless my(@files) = @_
1549 7 22 if (UNIVERSAL::isa($file, "Archive::Tar::File"))
1555 0 22 if (utf8::is_utf8($file))
1560 0 22 unless (-e $file or -l $file)
1566 0 22 unless ($obj)
1637 1 13 unless ($obj)
1667 15 0 if (ref $self)
1674 6 9 if ($Archive::Tar::WARN)
1675 0 6 $Archive::Tar::DEBUG ? :
1683 20 2 if (ref $self) { }
1684 0 20 shift() ? :
1686 0 2 shift() ? :
1775 0 9 unless defined $file
1779 0 9 unless (@files)
1817 0 15 unless defined $filename
1822 0 15 unless my $handle = $class->_get_handle($filename, $compressed, sub { package Archive::Tar::Constant; use warnings; use strict; shift() ? 'rb' : 'r';}->(1))
1831 2 33 if @data
1832 0 33 unless $handle
1836 33 0 if ref $tarfile and ref $tarfile eq "ARRAY"
1837 33 0 unless ($Archive::Tar::RESOLVE_SYMLINK =~ /none/)
1840 1 19 if ($_->linkname)
1848 18 15 if @data
1852 0 15 if (@$CONSTRUCT_ARGS == 4)
1882 0 3 unless defined $file
1886 0 3 unless $tar
1907 0 9 unless defined $file
1910 0 9 unless my $tar = $class->new
1992 0 0 if (@trg and $trg[0] eq "")
1998 0 0 if $part eq "."
1999 0 0 if ($part eq '..') { }
2009 0 0 if $Archive::Tar::DEBUG