Branch Coverage

lib/Archive/Tar.pm
Criterion Covered Total %
branch 248 426 58.2


line true false branch
115 103 360 if @_
122 0 74 if ref $class
128 17 57 if (@_)
129 0 17 unless ($obj->read(@_))
209 50 2 if (defined $file) { }
216 0 50 unless my $handle = $self->_get_handle($file, $gzip, sub { ; } ->(1))
219 2 48 unless my $data = $self->_read_tar($handle, $opts)
223 5 43 wantarray ? :
228 0 92 unless defined $file
233 0 92 if (ref $file)
234 0 0 if eval { do { *$file{'IO'} } }
235 0 0 if eval { do { $file->isa('IO::Handle') } }
245 62 30 if (sub { ; } ->($mode))
246 0 62 unless (open my $tmp, $file)
260 20 72 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' }) { }
59 13 elsif ($compress or sub { package Archive::Tar::Constant; use warnings; $_[0] =~ /^r/ ? 1 : 0; } ->($mode) or $magic =~ /^(?:\037\213|\037\235)/) { }
284 81 11 unless $compress eq 'bzip2'
291 12 8 if (sub { package Archive::Tar::Constant; use warnings; $_[0] =~ /^r/ ? 1 : 0; } ->($mode)) { }
292 0 12 unless ($fh = 'IO::Uncompress::Bunzip2'->new($file, 'MultiStream', 1))
300 0 8 unless ($fh = 'IO::Compress::Bzip2'->new($file))
317 0 59 unless ($fh->open($file, $mode))
326 0 13 unless ($fh->open($file, $mode))
342 0 77 unless my $handle = shift()
353 28 49 if $count > 0
366 105 500 if (ref $handle ne 'IO::Zlib') { }
375 73 532 unless ($read++)
377 0 73 if ($chunk =~ /$gzip/)
384 2 71 if (length $chunk != 512)
391 1 602 if length $chunk != 512
396 334 268 if $chunk eq "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
404 0 268 unless ($nulls eq substr($chunk, 500, 12))
415 61 207 if defined $real_name
417 0 268 unless ($entry = 'Archive::Tar::File'->new('chunk', $chunk, %extra_args))
427 0 268 if $entry->is_label
429 202 66 if (length $entry->type and $entry->is_file || $entry->is_longlink)
431 0 202 if ($entry->is_file and not $entry->validate)
436 0 0 if length $name > 100
451 0 202 if ($md5) { }
22 180 elsif ($filter and not $entry->name =~ /$filter/) { }
22 158 elsif ($filter_cb and not &$filter_cb($entry)) { }
0 158 elsif ($entry->name eq 'pax_global_header' or $entry->type =~ /^(x|g)$/) { }
468 44 158 if ($skip) { }
480 44 0 if $this > $amt
481 0 44 if ($handle->read($$data, $this) < $this)
488 44 0 if $fsz < 0
489 0 44 if $skip == 5
491 0 0 if $skip == 5 and not $entry->is_longlink and not $entry->is_unknown and not $entry->is_label
498 0 158 if ($handle->read($$data, $block) < $block)
504 158 0 if defined $$data
509 61 141 if ($entry->is_longlink)
537 61 207 if ($entry->is_longlink) { }
61 146 elsif (defined $real_name) { }
546 20 187 if ($filter and not $entry->name =~ /$filter/) { }
20 167 elsif ($filter_cb and not &$filter_cb($entry)) { }
0 167 elsif ($entry->name eq 'pax_global_header' or $entry->type =~ /^(x|g)$/) { }
559 9 0 if ($extract and not $entry->is_longlink and not $entry->is_unknown and not $entry->is_label)
562 0 9 unless $self->_extract_file($entry)
566 0 167 if $entry->name eq ''
570 9 158 $extract ? :
572 18 149 if ($limit)
573 12 6 unless $entry->is_longlink or $entry->is_dir
574 12 6 unless $count
599 0 2 unless defined $full
604 1 1 if $self->_find_entry($full)
633 13 0 unless $self->{'cwd'}
636 2 11 if (@args) { }
640 1 1 if (UNIVERSAL::isa($file, 'Archive::Tar::File')) { }
652 1 0 if (exists $hashmap->{$file}) { }
668 0 13 unless (scalar @files)
675 0 41 unless ($self->_extract_file($entry))
702 0 65 unless defined $file
705 0 65 unless my $entry = $self->_find_entry($file)
713 0 117 unless my $entry = shift()
717 61 56 defined $alt ? :
722 61 56 if (defined $alt) { }
732 30 87 if ($vol or 'File::Spec'->file_name_is_absolute($dirs)) { }
736 0 0 unless (defined $alt or $Archive::Tar::INSECURE_EXTRACT_MODE)
751 41 46 ref $self && defined $self->{'cwd'} ? :
753 31 56 defined $alt ? :
758 55 1 unless (defined $alt or $Archive::Tar::INSECURE_EXTRACT_MODE)
764 1 54 if (grep {$_ eq '..';} @dirs)
784 31 7 if ref $self and $self->{'_link_cache'}{$full_path}
786 0 15 if (-l $full_path)
800 7 8 if ref $self
813 86 0 if length $cwd_file
832 0 86 unless (defined $dir)
833 0 0 if $^W
839 0 116 if (-e $dir and not -d _)
840 0 0 if $^W
844 7 109 unless (-d _)
846 0 7 if ($@)
865 6 110 if $entry->is_dir
869 0 110 if ($entry->is_unknown)
882 9 101 if (-l $full or -e _)
883 0 9 unless (unlink $full)
888 108 2 if (length $entry->type and $entry->is_file) { }
890 0 108 unless $fh->open($full, '>')
895 98 10 if ($entry->size)
897 0 98 unless syswrite $fh, $entry->data
903 0 108 unless close $fh
909 0 2 unless $self->_make_special_file($entry, $full)
915 108 2 unless (-l $full)
916 0 108 unless utime time, $entry->mtime - 0, $full
920 108 2 if ($Archive::Tar::CHOWN and sub { ; } ->() and not -l $full)
921 0 108 unless CORE::chown $entry->uid, $entry->gid, $full
927 108 2 if ($Archive::Tar::CHMOD and not -l $full)
929 0 108 unless ($Archive::Tar::SAME_PERMISSIONS)
932 0 108 unless CORE::chmod $mode, $full
941 0 2 unless my $entry = shift()
942 0 2 unless defined $file
946 2 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) { }
949 0 2 unless symlink $entry->linkname, $file
956 0 2 if $fail
962 0 0 unless link $entry->linkname, $file
969 0 0 if $fail
973 0 0 if system 'mknod', $file, 'p'
977 0 0 $entry->is_blockdev ? :
979 0 0 if system 'mknod', $file, $mode, $entry->devmajor, $entry->devminor
990 0 2 $err ? :
997 0 0 unless my $entry = shift()
998 0 0 unless defined $file
1004 0 0 unless ($orig)
1013 0 0 unless $self->_extract_file($clone, $file)
1042 0 31 unless ($self->_data)
1043 0 0 unless $self->read
1046 31 0 if (@$aref == 0 or @$aref == 1 and $aref->[0] eq 'name') { }
1068 0 118 unless (defined $file)
1074 16 102 if UNIVERSAL::isa($file, 'Archive::Tar::File')
1077 102 0 if ($self->_data)
1080 99 151 if $path eq $file
1084 3 0 unless ($Archive::Tar::RESOLVE_SYMLINK =~ /none/)
1085 0 3 if (my $link_entry = shift())
1087 0 0 if $self->_data
1092 0 0 if ($Archive::Tar::RESOLVE_SYMLINK =~ /speed/ and @$iterargs == 3)
1098 0 0 if ($archive->_data)
1108 0 0 if ($e->full_path eq $file)
1135 59 4 unless @_
1153 0 11 unless my $entry = $self->_find_entry(shift())
1166 0 1 unless my $entry = $self->_find_entry(shift())
1184 0 2 unless defined $file
1185 0 2 unless defined $new
1187 0 2 unless my $entry = $self->_find_entry($file)
1202 0 1 unless defined $file
1203 0 1 unless defined $mode and $mode =~ /^[0-7]{1,4}$/
1206 0 1 unless my $entry = $self->_find_entry($file)
1221 0 2 unless defined $file
1222 0 2 unless defined $uname
1226 0 2 unless my $entry = $self->_find_entry($file)
1260 0 2 unless my $self = shift()
1308 3 30 unless defined $file
1310 33 0 unless defined $ext_prefix
1317 0 0 $Archive::Tar::HAS_IO_STRING ? :
3 0 $Archive::Tar::HAS_PERLIO ? :
30 3 length $file ? :
1338 4 83 if ($Archive::Tar::DO_NOT_USE_PREFIX) { }
1342 0 4 length $ext_prefix ? :
1357 0 83 if length $ext_prefix
1371 15 72 if ($make_longlink)
1378 0 15 unless ($longlink)
1402 0 102 if $link_ok
1406 0 102 unless ($header)
1412 0 102 unless (print $handle $header)
1418 80 22 if ($link_ok or $data_ok)
1419 0 80 unless (print $handle $clone->data)
1426 80 0 if $clone->size % 512
1433 0 33 unless print $handle "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
1439 3 0 $Archive::Tar::HAS_PERLIO ? :
30 3 length $file ? :
1442 33 0 if ($file ne $handle)
1443 0 33 unless (close $handle)
1454 0 102 unless my $entry = shift()
1455 102 0 unless defined $ext_prefix
1459 0 102 unless defined $prefix
1470 0 102 if length $ext_prefix
1475 7 95 if length $prefix >= 155
1477 0 102 $Archive::Tar::ZERO_PAD_NUMBERS ? :
1494 0 102 $no_prefix ? :
1500 0 102 $Archive::Tar::ZERO_PAD_NUMBERS ? :
1530 0 24 unless my(@files) = @_
1538 25 16 if (UNIVERSAL::isa($file, 'Archive::Tar::File'))
1544 0 16 if (utf8::is_utf8($file))
1549 0 16 unless (-e $file or -l $file)
1555 0 16 unless ($obj)
1626 1 14 unless ($obj)
1656 9 0 if (ref $self)
1663 0 9 if ($Archive::Tar::WARN)
1664 0 0 $Archive::Tar::DEBUG ? :
1672 20 2 if (ref $self) { }
1673 0 20 shift() ? :
1675 0 2 shift() ? :
1764 0 9 unless defined $file
1768 0 9 unless (@files)
1806 0 12 unless defined $filename
1811 0 12 unless my $handle = $class->_get_handle($filename, $compressed, sub { ; } ->(1))
1820 2 27 if @data
1821 0 27 unless $handle
1825 27 0 if ref $tarfile and ref $tarfile eq 'ARRAY'
1826 27 0 unless ($Archive::Tar::RESOLVE_SYMLINK =~ /none/)
1829 1 16 if ($_->linkname)
1837 15 12 if @data
1841 0 12 if (@$CONSTRUCT_ARGS == 4)
1871 0 3 unless defined $file
1875 0 3 unless $tar
1896 0 9 unless defined $file
1899 0 9 unless my $tar = $class->new
1981 0 0 if (@trg and $trg[0] eq '')
1987 0 0 if $part eq '.'
1988 0 0 if ($part eq '..') { }
1998 0 0 if $Archive::Tar::DEBUG