| 1 | # Copyright (c) 2024-2026 Philipp Schafft <lion@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # licensed under Artistic License 2.0 (see LICENSE file) | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: generic module for extracting information from filesystems | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | package File::Information; | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use v5.16; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use Fcntl qw(S_ISBLK); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use File::Information::Link; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use File::Information::Inode; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use File::Information::Filesystem; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use File::Information::Tagpool; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use parent 'Data::Identifier::Interface::Known'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | our $VERSION = v0.17; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | my $HAVE_FILE_VALUEFILE = eval {require File::ValueFile::Simple::Reader; 1;}; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | my $HAVE_UNIX_MKNOD = eval {require Unix::Mknod; 1;}; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | my %_new_subobjects = ( | |||||||||||||||||||||||||||||||||||||||||
| 32 | extractor => 'Data::URIID', | ||||||||||||||||||||||||||||||||||||||||||
| 33 | db => 'Data::TagDB', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=21 SCAR=43.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | my ($pkg, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | my $self = bless {}; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | foreach my $key (keys %_new_subobjects) { | |||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | if (defined($opts{$key})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | croak 'Bad package for option '.$key unless eval {$opts{$key}->isa($_new_subobjects{$key})}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $self->{$key} = $opts{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | $self->{$_} = $opts{$_} foreach qw(tagpool_rc tagpool_path device_path digest_sizelimit mountinfo_path boring_sizelimit boring_extension store); | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | ▶ | $self->{store} //= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"store"} //= []
MC/DC0%0/1
$self->{"store"} //= []
$self->{"store"}
Truth table50%1/2
A
A= $self->{"store"}
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | $self->{store} = [$self->{store}] unless ref($self->{store}) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | foreach my $store (@{$self->{store}}) { | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | unless (eval {$store->isa('File::FStore')}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | require File::FStore; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $store = File::FStore->new(path => $store); | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $store->attach(db => $self->{db}, extractor => $self->{extractor}, fii => $self, weak => 1); | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | $self->{digest_sizelimit} //= 512*1024*1024; # 512MB | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"digest_sizelimit"} //= 536870912
MC/DC0%0/1
$self->{"digest_sizelimit"} //= 536870912
$self->{"digest_sizelimit"}
Truth table50%1/2
A
A= $self->{"digest_sizelimit"}
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | if ($self->{digest_sizelimit} eq 'infinite') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->{digest_sizelimit} = -1; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | $self->{digest_sizelimit} = int($self->{digest_sizelimit}); # ensure it's an int. This will also set to 0 in case of error. | |||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | ▶ | $self->{digest_sizelimit} = 0 if $self->{digest_sizelimit} < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | ▶ | $self->{boring_sizelimit} //= 128; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"boring_sizelimit"} //= 128
MC/DC0%0/1
$self->{"boring_sizelimit"} //= 128
$self->{"boring_sizelimit"}
Truth table50%1/2
A
A= $self->{"boring_sizelimit"}
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | $self->{boring_sizelimit} = int($self->{boring_sizelimit}); | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | ▶ | $self->{boring_extension} //= [qw(o bakX old orig part rej swp tmp dpkg-dist dpkg-old ucf-dist ucf-new ucf-old rpmnew rpmorig rpmsave)]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"boring_extension"} //= ["o", "bakX", "old", "orig", "part", "rej", "swp", "tmp", "dpkg-dist", "dpkg-old", "ucf-dist", "ucf-new", "ucf-old", "rpmnew", "rpmorig", "rpmsave"]
MC/DC0%0/1
$self->{"boring_extension"} //= ["o", "bakX", "old", "orig", "part", "rej", "swp", "tmp", "dpkg-dist", "dpkg-old", "ucf-dist", "ucf-new", "ucf-old", "rpmnew", "rpmorig", "rpmsave"]
$self->{"boring_extension"}
Truth table50%1/2
A
A= $self->{"boring_extension"}
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | $self->{boring_extension} = [split/(?:\s*,\s*|\s+)/, $self->{boring_extension}] unless ref $self->{boring_extension}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | $self->{boring_extension} = {map {fc($_) => 1} @{$self->{boring_extension}}}; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | if (defined(my $boring_extension_add = $opts{boring_extension_add})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | $boring_extension_add = [split/(?:\s*,\s*|\s+)/, $boring_extension_add] unless ref $boring_extension_add; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $self->{boring_extension}{fc($_)} = 1 foreach @{$boring_extension_add}; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | if (defined $opts{digest_unsafe}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $unsafe = $opts{digest_unsafe}; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | $unsafe = [$unsafe] unless ref($unsafe) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $_->{unsafe} = 1 foreach $self->digest_info(@{$unsafe}); | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | $self->_tagpool_locate; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | sub for_link { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
for_link: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | my ($self, %opts); | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | ▶ | if (scalar(@_) == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | ($self, $opts{path}) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | ▶ | $opts{symlinks} //= 'nofollow'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"symlinks"} //= "nofollow"
MC/DC0%0/1
$opts{"symlinks"} //= "nofollow"
$opts{"symlinks"}
Truth table50%1/2
A
A= $opts{"symlinks"}
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | return File::Information::Link->_new(instance => $self, (map {$_ => $opts{$_}} qw(path symlinks))); | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | #@returns File::Information::Inode | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub for_handle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
for_handle: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my ($self, %opts); | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if (scalar(@_) == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ($self, $opts{handle}) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | return File::Information::Inode->_new(instance => $self, (map {$_ => $opts{$_}} qw(handle))); | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | #@returns File::Information::Base | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | sub for_identifier { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
for_identifier: not called CC=27 SCAR=66.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my ($self, %opts); | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if (scalar(@_) == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ($self, $opts{identifier}) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } elsif (scalar(@_) == 3) { | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ($self, $opts{type}, $opts{identifier}) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 136 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | croak 'No identifier given' unless defined $opts{identifier}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if (!defined($opts{type}) && ref($opts{identifier})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $opts{"type"} and ref $opts{"identifier"}
MC/DC0%0/2
not defined $opts{"type"} and ref $opts{"identifier"}
not defined $opts{"type"}
ref $opts{"identifier"}
Truth table0%0/3
not(A) and B
A= not defined $opts{"type"}B= ref $opts{"identifier"}
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $id = $opts{identifier}; | |||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ($id->isa('Data::URIID::Result')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $opts{type} = $id->id_type; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | unless (defined $opts{type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | # Special case: we might know a digest or something, but not an identifier. | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | require File::Information::Remote; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return File::Information::Remote->_new(instance => $self, data_uriid_result => $id); | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | } elsif ($id->isa('Data::Identifier')) { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $opts{type} = $id->type; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | croak 'No type given' unless defined $opts{type}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if (ref $opts{type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $opts{type} = $opts{type}->ise; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } elsif ($opts{type} eq 'uuid') { | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $opts{type} = '8be115d2-dc2f-4a98-91e1-a6e3075cbc31'; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if (ref(my $id = $opts{identifier})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if ($id->isa('Data::URIID::Result') || $id->isa('Data::Identifier')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$id->isa("Data::URIID::Result") or $id->isa("Data::Identifier")
MC/DC0%0/2
$id->isa("Data::URIID::Result") or $id->isa("Data::Identifier")
$id->isa("Data::URIID::Result")
$id->isa("Data::Identifier")
Truth table0%0/3
A or B
A= $id->isa("Data::URIID::Result")B= $id->isa("Data::Identifier")
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $opts{identifier} = $id->id; | |||||||||||||||||||||||||||||||||||||||||
| 168 | } elsif ($id->isa('Data::URIID::Base')) { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $opts{identifier} = $id->ise; | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if ($opts{type} eq '8be115d2-dc2f-4a98-91e1-a6e3075cbc31') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if ($opts{identifier} !~ /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | croak 'Invalid format for UUID'; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $self->_load_filesystems; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | foreach my $fs (values %{$self->{filesystems}}) { | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | my $ise = $fs->get('uuid', as => 'uuid', default => undef) // next; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$fs->get("uuid", "as", "uuid", "default", undef) // (next)
MC/DC0%0/1
$fs->get("uuid", "as", "uuid", "default", undef) // (next)
$fs->get("uuid", "as", "uuid", "default", undef)
Truth table0%0/2
A
A= $fs->get("uuid", "as", "uuid", "default", undef)
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | return $fs if $ise eq $opts{identifier}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | require File::ValueFile::Simple::Reader; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my $uuid = $opts{identifier}; | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | foreach my $pool ($self->tagpool) { | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $ise = $pool->get('uuid', as => 'uuid'); | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $hash; | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | return $pool if $ise eq $uuid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $hash = eval { | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $reader = File::ValueFile::Simple::Reader->new($pool->_catfile('data', 'info.'.$uuid)); | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $reader->read_as_hash; | |||||||||||||||||||||||||||||||||||||||||
| 199 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | next unless defined $hash; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | next unless defined $hash->{'pool-name-suffix'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | return $self->for_link(path => $pool->_catfile('data', $hash->{'pool-name-suffix'}), %opts); | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if (defined(my $extractor = eval {$self->extractor})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if (defined(my $result = eval {$extractor->lookup($opts{type}, $opts{identifier})})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | require File::Information::Remote; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | return File::Information::Remote->_new(instance => $self, data_uriid_result => $result); | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | croak 'Not found'; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | sub tagpool { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tagpool: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return values %{$self->_tagpool} | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | #@returns Data::URIID | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | sub extractor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extractor: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | return $self->{extractor} // croak 'No extractor available'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"extractor"} // croak("No extractor available")
MC/DC0%0/1
$self->{"extractor"} // croak("No extractor available")
$self->{"extractor"}
Truth table0%0/2
A
A= $self->{"extractor"}
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | #@returns Data::TagDB | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | sub db { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
db: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | return $self->{db} // croak 'No database available'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"db"} // croak("No database available")
MC/DC0%0/1
$self->{"db"} // croak("No database available")
$self->{"db"}
Truth table0%0/2
A
A= $self->{"db"}
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | ▶ | sub store { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
store: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | my $as = delete $opts{as}; | |||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | ▶ | croak 'Invalid as parameter' unless ($as // '') eq 'File::FStore'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$as // ""
MC/DC0%0/1
$as // ""
$as
Truth table50%1/2
A
A= $as
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | return @{$self->{store}}; | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | ▶ | sub lifecycles { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lifecycles: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | return qw(initial last current final); | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | ▶ | sub digest_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
digest_info: called CC=16 SCAR=34.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | my ($self, @algos) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | ▶ | if (scalar(@algos) == 1 && $algos[0] =~ /^v0m / && wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
scalar @algos == 1 and $algos[0] =~ /^v0m /u and wantarray
scalar @algos == 1 and $algos[0] =~ /^v0m /u
MC/DC0%0/3
scalar @algos == 1 and $algos[0] =~ /^v0m /u and wantarray
scalar @algos == 1
$algos[0] =~ /^v0m /u
wantarray
Truth table25%1/4
A and B and C
A= scalar @algos == 1B= $algos[0] =~ /^v0m /uC= wantarray
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | while ($algos[-1] =~ s#^v0m (\S+) bytes [0-9]+-[0-9]*/(?:[0-9]+|\*) [0-9a-f\.]+ ##) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | unshift(@algos, $1); | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | ▶ | unless ($self->{hash_info}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | my %hashes = map {$_ => { | |||||||||||||||||||||||||||||||||||||||||
| 267 | name => $_, | ||||||||||||||||||||||||||||||||||||||||||
| 268 | bits => int(($_ =~ /-([0-9]+)$/)[0]), | ||||||||||||||||||||||||||||||||||||||||||
| 269 | aliases => [], | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 20 | ▶ | %{$File::Information::Base::_digest_info_extra{$_}//{}}, | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$File::Information::Base::_digest_info_extra{$_} // {}
MC/DC100%1/1
$File::Information::Base::_digest_info_extra{$_} // {}
$File::Information::Base::_digest_info_extra{$_}
Truth table100%2/2
A
A= $File::Information::Base::_digest_info_extra{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | }} ( | ||||||||||||||||||||||||||||||||||||||||||
| 272 | values(%File::Information::Base::_digest_name_converter), | ||||||||||||||||||||||||||||||||||||||||||
| 273 | qw(md-4-128 ripemd-1-160 tiger-1-192 tiger-2-192), | ||||||||||||||||||||||||||||||||||||||||||
| 274 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | $self->{hash_info} = \%hashes; | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | $hashes{$_}{unsafe} = 1 foreach qw(md-4-128 md-5-128 sha-1-160); | |||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | push(@{$hashes{$File::Information::Base::_digest_name_converter{$_}}{aliases}}, $_) foreach keys %File::Information::Base::_digest_name_converter; | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 1 | ▶ | @algos = keys %{$self->{hash_info}} unless scalar @algos; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | ▶ | croak 'Request for more than one hash in scalar context' if !wantarray && scalar(@algos) != 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not wantarray and scalar @algos != 1
MC/DC0%0/2
not wantarray and scalar @algos != 1
not wantarray
scalar @algos != 1
Truth table33%1/3
not(A) and B
A= not wantarrayB= scalar @algos != 1
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | @ret = map{ | ||||||||||||||||||||||||||||||||||||||||||
| 286 | $self->{hash_info}{$_} || | ||||||||||||||||||||||||||||||||||||||||||
| 287 | 14 | ▶ | $self->{hash_info}{$File::Information::Base::_digest_name_converter{fc($_)} // ''} || | ||||||||||||||||||||||||||||||||||||||||
|
Condition28%2/7
$self->{'hash_info'}{$_} || $self->{'hash_info'}{$File::Information::Base::_digest_name_converter{fc $_} // ''} || croak('Unknown digest: ' . $_)
$self->{"hash_info"}{$_} or $self->{"hash_info"}{$File::Information::Base::_digest_name_converter{fc $_} // ""}
$File::Information::Base::_digest_name_converter{fc $_} // ""
MC/DC0%0/2
$self->{'hash_info'}{$_} || $self->{'hash_info'}{$File::Information::Base::_digest_name_converter{fc $_} // ''} || croak('Unknown digest: ' . $_)
$self->{"hash_info"}{$_}
$self->{"hash_info"}{$File::Information::Base::_digest_name_converter{fc $_} // ""}
MC/DC0%0/1
$File::Information::Base::_digest_name_converter{fc $_} // ""
$File::Information::Base::_digest_name_converter{fc $_}
Truth table33%1/3
A or B
A= $self->{"hash_info"}{$_}B= $self->{"hash_info"}{$File::Information::Base::_digest_name_converter{fc $_} // ""}
Truth table0%0/2
A
A= $File::Information::Base::_digest_name_converter{fc $_}
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | croak 'Unknown digest: '.$_ | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | } map { s#^v0 (\S+) bytes [0-9]+-[0-9]*/(?:[0-9]+|\*) [0-9a-f\.]+$#$1#r } @algos; | |||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | return $ret[0]; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | # ---------------- | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 2 | ▶ | sub _home { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_home: called CC=12 SCAR=43.7
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 302 | 2 | my $home; | |||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | ▶ | return $self->{home} if defined $self->{home}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | ▶ | if ($^O eq 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | return $self->{home} = $home if defined($home = $ENV{USERPROFILE}) && length($home); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined($home = $ENV{"USERPROFILE"}) and length $home
MC/DC0%0/2
defined($home = $ENV{"USERPROFILE"}) and length $home
defined($home = $ENV{"USERPROFILE"})
length $home
Truth table0%0/3
A and B
A= defined($home = $ENV{"USERPROFILE"})B= length $home
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if (defined($ENV{HOMEDRIVE}) && defined($ENV{HOMEPATH})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $ENV{"HOMEDRIVE"} and defined $ENV{"HOMEPATH"}
MC/DC0%0/2
defined $ENV{"HOMEDRIVE"} and defined $ENV{"HOMEPATH"}
defined $ENV{"HOMEDRIVE"}
defined $ENV{"HOMEPATH"}
Truth table0%0/3
A and B
A= defined $ENV{"HOMEDRIVE"}B= defined $ENV{"HOMEPATH"}
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $home = $ENV{HOMEDRIVE}.$ENV{HOMEPATH}; | |||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | return $self->{home} = $home if length($home); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | return $self->{home} = 'C:\\'; | |||||||||||||||||||||||||||||||||||||||||
| 313 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 2 | ▶ | return $self->{home} = $home if defined($home = $ENV{HOME}) && length($home); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined($home = $ENV{"HOME"}) and length $home
MC/DC0%0/2
defined($home = $ENV{"HOME"}) and length $home
defined($home = $ENV{"HOME"})
length $home
Truth table33%1/3
A and B
A= defined($home = $ENV{"HOME"})B= length $home
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | return $self->{home} = $home if defined($home = eval { [getpwuid($>)]->[7] }) && length($home); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined($home = eval {
do {
[getpwuid $>]->[7]
}
}) and length $home
MC/DC0%0/2
defined($home = eval {
do {
[getpwuid $>]->[7]
}
}) and length $home
defined($home = eval {
do {
[getpwuid $>]->[7]
}
})
length $home
Truth table0%0/3
A and B
A= defined($home = eval {
do {
[getpwuid $>]->[7]
}
})B= length $home
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | return $self->{home} = File::Spec->rootdir; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | croak 'BUG'; | |||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | ▶ | sub _path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_path: called CC=10 SCAR=40.4
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 2 | my ($self, $xdg, $type, @el) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 2 | my $base; | |||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | ▶ | if (defined $xdg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | $base = $ENV{$xdg} // $self->{$xdg}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ENV{$xdg} // $self->{$xdg}
MC/DC0%0/2
$ENV{$xdg} // $self->{$xdg}
$ENV{$xdg}
$self->{$xdg}
Truth table0%0/3
A // B
A= $ENV{$xdg}B= $self->{$xdg}
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if (!defined($base) || !length($base)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $base and length $base
MC/DC0%0/2
defined $base and length $base
defined $base
length $base
Truth table0%0/3
A and B
A= defined $baseB= length $base
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | if ($xdg eq 'XDG_CACHE_HOME') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $base = File::Spec->catdir($self->_home, qw(.cache)); | |||||||||||||||||||||||||||||||||||||||||
| 331 | } elsif ($xdg eq 'XDG_DATA_HOME') { | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $base = File::Spec->catdir($self->_home, qw(.local share)); | |||||||||||||||||||||||||||||||||||||||||
| 333 | } elsif ($xdg eq 'XDG_CONFIG_HOME') { | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $base = File::Spec->catdir($self->_home, qw(.config)); | |||||||||||||||||||||||||||||||||||||||||
| 335 | } elsif ($xdg eq 'XDG_STATE_HOME') { | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $base = File::Spec->catdir($self->_home, qw(.local state)); | |||||||||||||||||||||||||||||||||||||||||
| 337 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | croak 'Unknown XDG path: '.$xdg; | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | $self->{$xdg} = $base; | |||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 2 | $base = $self->_home; | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 2 | ▶ | if ($type eq 'file') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 2 | return File::Spec->catfile($base, @el); | |||||||||||||||||||||||||||||||||||||||||
| 349 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | return File::Spec->catdir($base, @el); | |||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 2 | ▶ | sub _tagpool_locate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tagpool_locate: called CC=16 SCAR=40.9
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | my %candidates; | |||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 2 | ▶ | return unless $HAVE_FILE_VALUEFILE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 2 | ▶ | unless (defined $self->{tagpool_rc}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | # Set defaults: | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | $self->{tagpool_rc} = ['/etc/tagpoolrc', $self->_path(undef, file => '.tagpoolrc')]; # Values taken from tagpool as is. Should be updated. | |||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 2 | ▶ | unless (defined $self->{tagpool_path}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | # Set defaults: | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 2 | $self->{tagpool_path} = []; # none at this point. | |||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 2 | ▶ | $self->{tagpool_rc} = [$self->{tagpool_rc}] unless ref $self->{tagpool_rc}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | ▶ | $self->{tagpool_path} = [$self->{tagpool_path}] unless ref $self->{tagpool_path}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | %candidates = map {$_ => undef} grep {defined} @{$self->{tagpool_path}}; | |||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 2 | foreach my $tagpool_rc_path (@{$self->{tagpool_rc}}) { | |||||||||||||||||||||||||||||||||||||||||
| 376 | 4 | my $hash = eval {File::ValueFile::Simple::Reader->new($tagpool_rc_path)->read_as_hash}; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 4 | ▶ | if (defined $hash) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | foreach my $key (qw(pool-path pool)) { | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | if (defined $hash->{$key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $candidates{$hash->{$key}} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | # eliminate all but the ones that look like actual pools: | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 2 | foreach my $path (keys %candidates) { | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | unless (-d $path) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | delete $candidates{$path}; | |||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | foreach my $subdir (qw(data temp)) { | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | unless (-d File::Spec->catdir($path, $subdir)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | delete $candidates{$path}; | |||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | foreach my $subfile (qw(config)) { | |||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | unless (-f File::Spec->catfile($path, $subfile)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | delete $candidates{$path}; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 2 | $self->{tagpool_path} = [keys %candidates]; | |||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 2 | ▶ | sub _tagpool_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tagpool_path: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 2 | return $self->{tagpool_path}; | |||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 8 | ▶ | sub _tagpool_sysfile_cache { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tagpool_sysfile_cache: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 418 | 8 | ▶ | return $self->{_tagpool_sysfile_cache} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_tagpool_sysfile_cache"} //= {}
MC/DC100%1/1
$self->{"_tagpool_sysfile_cache"} //= {}
$self->{"_tagpool_sysfile_cache"}
Truth table100%2/2
A
A= $self->{"_tagpool_sysfile_cache"}
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | sub _tagpool { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tagpool: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 423 | my $pools = $self->{tagpool} //= { | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | map {$_ => File::Information::Tagpool->_new(instance => $self, path => $_)} @{$self->_tagpool_path} | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"tagpool"} //= {map({$_, "File::Information::Tagpool"->_new("instance", $self, "path", $_);} @{$self->_tagpool_path;})}
MC/DC0%0/1
$self->{"tagpool"} //= {map({$_, "File::Information::Tagpool"->_new("instance", $self, "path", $_);} @{$self->_tagpool_path;})}
$self->{"tagpool"}
Truth table0%0/2
A
A= $self->{"tagpool"}
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | return $pools; | |||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | sub _load_filesystems { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_filesystems: not called CC=40 SCAR=74.0
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | unless (defined $self->{filesystems}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my %dirs; | |||||||||||||||||||||||||||||||||||||||||
| 434 | my %found; | ||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my %filesystems; | |||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | $self->{device_path} //= File::Information::Filesystem->_default_device_search_paths; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"device_path"} //= "File::Information::Filesystem"->_default_device_search_paths
MC/DC0%0/2
$self->{"device_path"} //= "File::Information::Filesystem"->_default_device_search_paths
$self->{"device_path"}
"File::Information::Filesystem"->_default_device_search_paths
Truth table0%0/3
A //= B
A= $self->{"device_path"}B= "File::Information::Filesystem"->_default_device_search_paths
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | $self->{device_path} = [$self->{device_path}] unless ref($self->{device_path}) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | %dirs = map {$_ => undef} @{$self->{device_path}}; | |||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | foreach my $dir_path (keys %dirs) { | |||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | if (opendir(my $dir, $dir_path)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | while (my $entry = readdir($dir)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | my $devpath = File::Spec->catfile($dir_path, $entry); | |||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my @stat = stat($devpath); | |||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | next unless scalar @stat; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | next unless S_ISBLK($stat[2]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | $found{$stat[6]} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$found{$stat[6]} //= {}
MC/DC0%0/1
$found{$stat[6]} //= {}
$found{$stat[6]}
Truth table0%0/2
A
A= $found{$stat[6]}
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $found{$stat[6]}{stat} = \@stat; | |||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | $found{$stat[6]}{paths} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$found{$stat[6]}{"paths"} //= {}
MC/DC0%0/1
$found{$stat[6]}{"paths"} //= {}
$found{$stat[6]}{"paths"}
Truth table0%0/2
A
A= $found{$stat[6]}{"paths"}
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | $found{$stat[6]}{paths}{$dir_path} //= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$found{$stat[6]}{"paths"}{$dir_path} //= []
MC/DC0%0/1
$found{$stat[6]}{"paths"}{$dir_path} //= []
$found{$stat[6]}{"paths"}{$dir_path}
Truth table0%0/2
A
A= $found{$stat[6]}{"paths"}{$dir_path}
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | push(@{$found{$stat[6]}{paths}{$dir_path}}, $entry); | |||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | if ($^O eq 'MSWin32') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | foreach my $dos_device ('A'..'Z') { | |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $dos_path = $dos_device.':\\'; | |||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my @stat = stat($dos_path); | |||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | next unless scalar @stat; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | $found{$stat[0]} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$found{$stat[0]} //= {}
MC/DC0%0/1
$found{$stat[0]} //= {}
$found{$stat[0]}
Truth table0%0/2
A
A= $found{$stat[0]}
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $found{$stat[0]}{dirstat} = \@stat; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $found{$stat[0]}{dos_device} = $dos_device; | |||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $found{$stat[0]}{dos_path} = $dos_path; | |||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | $found{$stat[0]}{paths} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$found{$stat[0]}{"paths"} //= {}
MC/DC0%0/1
$found{$stat[0]}{"paths"} //= {}
$found{$stat[0]}{"paths"}
Truth table0%0/2
A
A= $found{$stat[0]}{"paths"}
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | if ($HAVE_UNIX_MKNOD && $^O eq 'linux') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$HAVE_UNIX_MKNOD and $^O eq "linux"
MC/DC0%0/2
$HAVE_UNIX_MKNOD and $^O eq "linux"
$HAVE_UNIX_MKNOD
$^O eq "linux"
Truth table0%0/3
A and B
A= $HAVE_UNIX_MKNODB= $^O eq "linux"
| |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | $self->{mountinfo_path} //= '/proc/self/mountinfo'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"mountinfo_path"} //= "/proc/self/mountinfo"
MC/DC0%0/1
$self->{"mountinfo_path"} //= "/proc/self/mountinfo"
$self->{"mountinfo_path"}
Truth table0%0/2
A
A= $self->{"mountinfo_path"}
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | if (open(my $mountinfo, '<', $self->{mountinfo_path})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | while (defined(my $line = <$mountinfo>)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my ($mount_id, $parent_id, $major, $minor, $root, $mountpoint, $mount_options, $options, $fs_type, $source, $super_options) = | |||||||||||||||||||||||||||||||||||||||||
| 481 | $line =~ m#^(\S+)\s+(\S+)\s+([0-9]+):([0-9]+)\s+(/\S*)\s+(/\S*)\s+(\S+)\s+((?:\S+:\S+\s+)*)-\s+(\S+)\s+(/\S+|none|\S+)\s+(\S+)$#; | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my $dev; | |||||||||||||||||||||||||||||||||||||||||
| 483 | my $entry; | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | next unless defined $mount_id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | s/\\([0-9]{3})/chr(oct($1))/ge foreach $mount_id, $parent_id, $major, $minor, $root, $mountpoint, $mount_options, $options, $fs_type, $source, $super_options; | |||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $dev = Unix::Mknod::makedev($major, $minor); | |||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | $entry = $found{$dev} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$found{$dev} //= {}
MC/DC0%0/1
$found{$dev} //= {}
$found{$dev}
Truth table0%0/2
A
A= $found{$dev}
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | $entry->{paths} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$entry->{"paths"} //= {}
MC/DC0%0/1
$entry->{"paths"} //= {}
$entry->{"paths"}
Truth table0%0/2
A
A= $entry->{"paths"}
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | if (!defined($entry->{stat}) && $source =~ m#^/#) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $entry->{"stat"} and $source =~ m[^/]u
MC/DC0%0/2
not defined $entry->{"stat"} and $source =~ m[^/]u
not defined $entry->{"stat"}
$source =~ m[^/]u
Truth table0%0/3
not(A) and B
A= not defined $entry->{"stat"}B= $source =~ m[^/]u
| |||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | my @stat = eval {stat($source)}; | |||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | $entry->{stat} = \@stat if scalar @stat; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if (!defined($entry->{dirstat}) && $mountpoint =~ m#^/#) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $entry->{"dirstat"} and $mountpoint =~ m[^/]u
MC/DC0%0/2
not defined $entry->{"dirstat"} and $mountpoint =~ m[^/]u
not defined $entry->{"dirstat"}
$mountpoint =~ m[^/]u
Truth table0%0/3
not(A) and B
A= not defined $entry->{"dirstat"}B= $mountpoint =~ m[^/]u
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | my @stat = eval {stat($mountpoint)}; | |||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | $entry->{dirstat} = \@stat if scalar @stat; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | $entry->{mountpoint} //= $mountpoint if $mountpoint =~ m#^/#; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$entry->{"mountpoint"} //= $mountpoint
MC/DC0%0/2
$entry->{"mountpoint"} //= $mountpoint
$entry->{"mountpoint"}
$mountpoint
Truth table0%0/3
A //= B
A= $entry->{"mountpoint"}B= $mountpoint
| |||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | $entry->{fs_type} //= $fs_type; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$entry->{"fs_type"} //= $fs_type
MC/DC0%0/2
$entry->{"fs_type"} //= $fs_type
$entry->{"fs_type"}
$fs_type
Truth table0%0/3
A //= B
A= $entry->{"fs_type"}B= $fs_type
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | $entry->{linux_mount_options} //= $mount_options; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$entry->{"linux_mount_options"} //= $mount_options
MC/DC0%0/2
$entry->{"linux_mount_options"} //= $mount_options
$entry->{"linux_mount_options"}
$mount_options
Truth table0%0/3
A //= B
A= $entry->{"linux_mount_options"}B= $mount_options
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | $entry->{linux_superblock_options} //= $super_options; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$entry->{"linux_superblock_options"} //= $super_options
MC/DC0%0/2
$entry->{"linux_superblock_options"} //= $super_options
$entry->{"linux_superblock_options"}
$super_options
Truth table0%0/3
A //= B
A= $entry->{"linux_superblock_options"}B= $super_options
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | if ($source =~ m#^/#) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | my ($volume, $directories, $file) = File::Spec->splitpath($source); | |||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $dir = File::Spec->catdir($volume, $directories); | |||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | $entry->{paths}{$dir} //= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$entry->{"paths"}{$dir} //= []
MC/DC0%0/1
$entry->{"paths"}{$dir} //= []
$entry->{"paths"}{$dir}
Truth table0%0/2
A
A= $entry->{"paths"}{$dir}
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | push(@{$entry->{paths}{$dir}}, $file); | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | foreach my $key (keys %found) { | |||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | $filesystems{$key} = File::Information::Filesystem->_new(instance => $self, %{$found{$key}}); | |||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $self->{dev_found} = \%found; | |||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $self->{filesystems} = \%filesystems; | |||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | sub _filesystem_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filesystem_for: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | my ($self, $dev) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | $self->_load_filesystems; | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | return $self->{filesystems}{$dev}; | |||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | # --- Overrides for Data::Identifier::Interface::Known --- | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | sub _known_provider { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_known_provider: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my ($pkg, $class, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | croak 'Unsupported options passed' if scalar(keys %opts); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | if ($class eq 'lifecycles_name') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | return ([$pkg->lifecycles], not_identifiers => 1); | |||||||||||||||||||||||||||||||||||||||||
| 542 | } elsif ($class eq 'digest_name') { | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | return ([map {$_->{name}} $pkg->digest_info], not_identifiers => 1); | |||||||||||||||||||||||||||||||||||||||||
| 544 | } elsif ($class eq 'digest') { | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | state $type = Data::Identifier->new(uuid => '8db88212-69df-40f3-a5cf-105dcd853d44')->register; | |||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | require Data::Identifier; | |||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | require Data::Identifier::Wellknown; | |||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | Data::Identifier::Wellknown->import('digest-algorithm'); | |||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | return ([map {Data::Identifier->new($type => $_->{name})} $pkg->digest_info], rawtype => 'Data::Identifier'); | |||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | return ([]) if $class eq ':all'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | croak 'Unsupported class'; | |||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | __END__ | ||||||||||||||||||||||||||||||||||||||||||