Branch Coverage

lib/Archive/Tar.pm
Criterion Covered Total %
branch 255 442 57.6


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 117 10 unless (defined $alt or $Archive::Tar::INSECURE_EXTRACT_MODE)
767 1 116 if (grep {$_ eq "..";} @dirs)
787 90 11 if ref $self and $self->{'_link_cache'}{$full_path}
789 2 12 if (-l $full_path)
803 9 3 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) { }
958 2 4 unless ($Archive::Tar::INSECURE_EXTRACT_MODE)
960 0 2 if ("File::Spec"->file_name_is_absolute($linkname))
965 0 2 if (grep {$_ eq "..";} "File::Spec"->splitdir($linkname))
973 0 6 unless symlink $entry->linkname, $file
980 0 6 if $fail
984 0 0 unless ($Archive::Tar::INSECURE_EXTRACT_MODE)
986 0 0 if ("File::Spec"->file_name_is_absolute($linkname))
993 0 0 if (grep {$_ eq "..";} "File::Spec"->splitdir($linkname))
1002 0 0 if ($Archive::Tar::EXTRACT_HARDLINK) { }
1003 0 0 unless link $entry->linkname, $file
1006 0 0 unless $self->_extract_special_file_as_plain_file($entry, $file)
1010 0 0 if $fail
1014 0 0 if system "mknod", $file, "p"
1018 0 0 $entry->is_blockdev ? :
1020 0 0 if system "mknod", $file, $mode, $entry->devmajor, $entry->devminor
1031 0 6 $err ? :
1038 0 0 unless my $entry = shift()
1039 0 0 unless defined $file
1045 0 0 unless ($orig)
1054 0 0 unless $self->_extract_file($clone, $file)
1083 0 38 unless ($self->_data)
1084 0 0 unless $self->read
1087 38 0 if (@$aref == 0 or @$aref == 1 and $aref->[0] eq 'name') { }
1109 0 218 unless (defined $file)
1115 16 202 if UNIVERSAL::isa($file, "Archive::Tar::File")
1118 202 0 if ($self->_data)
1121 199 311 if $path eq $file
1125 3 0 unless ($Archive::Tar::RESOLVE_SYMLINK =~ /none/)
1126 0 3 if (my $link_entry = shift())
1128 0 0 if $self->_data
1133 0 0 if ($Archive::Tar::RESOLVE_SYMLINK =~ /speed/ and @$iterargs == 3)
1139 0 0 if ($archive->_data)
1149 0 0 if ($e->full_path eq $file)
1176 105 4 unless @_
1194 0 11 unless my $entry = $self->_find_entry(shift())
1207 0 1 unless my $entry = $self->_find_entry(shift())
1225 0 2 unless defined $file
1226 0 2 unless defined $new
1228 0 2 unless my $entry = $self->_find_entry($file)
1243 0 1 unless defined $file
1244 0 1 unless defined $mode and $mode =~ /^[0-7]{1,4}$/
1247 0 1 unless my $entry = $self->_find_entry($file)
1262 0 2 unless defined $file
1263 0 2 unless defined $uname
1267 0 2 unless my $entry = $self->_find_entry($file)
1301 0 2 unless my $self = shift()
1349 3 30 unless defined $file
1351 33 0 unless defined $ext_prefix
1358 0 0 $Archive::Tar::HAS_IO_STRING ? :
3 0 $Archive::Tar::HAS_PERLIO ? :
30 3 length $file ? :
1379 4 70 if ($Archive::Tar::DO_NOT_USE_PREFIX) { }
1383 0 4 length $ext_prefix ? :
1398 0 70 if length $ext_prefix
1412 9 65 if ($make_longlink)
1419 0 9 unless ($longlink)
1443 0 83 if $link_ok
1447 0 83 unless ($header)
1453 0 83 unless (print $handle $header)
1459 70 13 if ($link_ok or $data_ok)
1460 0 70 unless (print $handle $clone->data)
1467 70 0 if $clone->size % 512
1474 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\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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"
1480 3 0 $Archive::Tar::HAS_PERLIO ? :
30 3 length $file ? :
1483 33 0 if ($file ne $handle)
1484 0 33 unless (close $handle)
1495 0 83 unless my $entry = shift()
1496 83 0 unless defined $ext_prefix
1500 0 83 unless defined $prefix
1511 0 83 if length $ext_prefix
1516 4 79 if length $prefix >= 155
1518 0 83 $Archive::Tar::ZERO_PAD_NUMBERS ? :
1535 0 83 $no_prefix ? :
1541 0 83 $Archive::Tar::ZERO_PAD_NUMBERS ? :
1571 0 25 unless my(@files) = @_
1579 7 22 if (UNIVERSAL::isa($file, "Archive::Tar::File"))
1585 0 22 if (utf8::is_utf8($file))
1590 0 22 unless (-e $file or -l $file)
1596 0 22 unless ($obj)
1667 1 13 unless ($obj)
1697 15 0 if (ref $self)
1704 6 9 if ($Archive::Tar::WARN)
1705 0 6 $Archive::Tar::DEBUG ? :
1713 20 2 if (ref $self) { }
1714 0 20 shift() ? :
1716 0 2 shift() ? :
1805 0 9 unless defined $file
1809 0 9 unless (@files)
1847 0 15 unless defined $filename
1852 0 15 unless my $handle = $class->_get_handle($filename, $compressed, sub { package Archive::Tar::Constant; use warnings; use strict; shift() ? 'rb' : 'r';}->(1))
1861 2 33 if @data
1862 0 33 unless $handle
1866 33 0 if ref $tarfile and ref $tarfile eq "ARRAY"
1867 33 0 unless ($Archive::Tar::RESOLVE_SYMLINK =~ /none/)
1870 1 19 if ($_->linkname)
1878 18 15 if @data
1882 0 15 if (@$CONSTRUCT_ARGS == 4)
1912 0 3 unless defined $file
1916 0 3 unless $tar
1937 0 9 unless defined $file
1940 0 9 unless my $tar = $class->new
2022 0 0 if (@trg and $trg[0] eq "")
2028 0 0 if $part eq "."
2029 0 0 if ($part eq '..') { }
2039 0 0 if $Archive::Tar::DEBUG