| 1 | package YATT::Lite::VFS; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 78 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 78 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 78 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 78 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 78 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 78 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 78 | ▶ | use constant DEBUG_VFS => $ENV{DEBUG_YATT_VFS}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 78 | ▶ | use constant DEBUG_REBUILD => $ENV{DEBUG_YATT_REBUILD}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 78 | ▶ | use constant DEBUG_MRO => $ENV{DEBUG_YATT_MRO}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 78 | ▶ | use constant DEBUG_LOOKUP => $ENV{DEBUG_YATT_VFS_LOOKUP}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 78 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | 78 | require File::Basename; | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | 78 | require File::Glob; | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # VFS 層. vfs_file (Template) のダミー実装を含む。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | sub MY () {__PACKAGE__} | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | use YATT::Lite::Types | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 78 | ▶ | ([Item => -fields => [qw(name public type)] | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | , -constants => [[can_generate_code => 0], [item_category => '']] | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | , [Folder => -fields => [qw(_Item path parent base | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | _argmacro_dict | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | entns)] | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | , -eval => q{use YATT::Lite::Util qw(cached_in);} | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | , [File => -fields => [qw(_partlist _boundarylist | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | string overlay imported | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | nlines | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | _dependency | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | _dependents | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | )] | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | , -alias => 'vfs_file'] | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | , [Dir => -fields => [qw(encoding page_prefix)] | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 78 | , -alias => 'vfs_dir']]]); | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub YATT::Lite::VFS::Item::after_create {} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_create: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # item_key の符号化は class メソッド item_key_for($name) に集約する。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # Action/Entity などの subclass (YATT::Lite::Core) が override する。GH-256 | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1403 | ▶ | sub YATT::Lite::VFS::Item::item_key_for { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
item_key_for: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1403 | (my $class, my $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1403 | $name; | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 973 | ▶ | sub YATT::Lite::VFS::Item::item_key { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
item_key: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 973 | (my Item $item) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 973 | $item->item_key_for($item->{name}); | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # 通常の Item は自分自身を返す。<!yatt:import> の alias Part | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # (YATT::Lite::Core::Import) がこれを override する。GH-256 | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 719 | ▶ | sub YATT::Lite::VFS::Item::resolve_alias { $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_alias: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 626 | ▶ | sub YATT::Lite::VFS::Folder::configure_parent { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure_parent: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 626 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | # 循環参照対策 | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # XXX: Item に移すべきかもしれない。そうすれば、 Widget->parent が引ける。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 626 | weaken($self->{parent} = shift); | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub YATT::Lite::VFS::Folder::get_linear_isa_of_entns { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_linear_isa_of_entns: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | (my Folder $folder) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $isa = mro::get_linear_isa($folder->{entns}); | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | wantarray ? @$isa : $isa; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub YATT::Lite::VFS::Folder::list_parts { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_parts: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | (my Folder $folder) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | return unless $folder->{_Item}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | values %{$folder->{_Item}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 78 | ▶ | sub YATT::Lite::VFS::File::page_name { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
page_name: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 78 | (my File $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | 78 | my Dir $parent = $file->{parent}; | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 78 | ▶ | return undef unless defined $parent->{page_prefix}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 73 | $parent->{page_prefix} . $file->{name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 78 | ▶ | package YATT::Lite::VFS; BEGIN {$INC{"YATT/Lite/VFS.pm"} = 1} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | sub VFS () {__PACKAGE__} | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 78 | ▶ | use parent qw(YATT::Lite::Object); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 78 | ▶ | use YATT::Lite::MFields qw/ext_private ext_public cache no_auto_create | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | facade base | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | import | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | entns | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | always_refresh_deps | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | no_mro_c3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | _on_memory | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | _root _extdict | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | mark | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | _n_creates | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 78 | entns2vfs_item/; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | 78 | ▶ | use YATT::Lite::Util qw(lexpand rootname extname); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub default_ext_public {'yatt'} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_ext_public: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub default_ext_private {'ytmpl'} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_ext_private: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 257 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=23.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 257 | my ($class, $spec) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | 257 | (my VFS $vfs, my @task) = $class->SUPER::just_new(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | 257 | ▶ | foreach my $desc ([1, ($vfs->{ext_public} | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$vfs->{"ext_public"} ||= $vfs->default_ext_public
$vfs->{"ext_private"} ||= $vfs->default_ext_private
MC/DC0%0/2
$vfs->{"ext_public"} ||= $vfs->default_ext_public
$vfs->{"ext_public"}
$vfs->default_ext_public
MC/DC0%0/2
$vfs->{"ext_private"} ||= $vfs->default_ext_private
$vfs->{"ext_private"}
$vfs->default_ext_private
Truth table33%1/3
A ||= B
A= $vfs->{"ext_public"}B= $vfs->default_ext_public
Truth table33%1/3
A ||= B
A= $vfs->{"ext_private"}B= $vfs->default_ext_private
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ||= $vfs->default_ext_public)] | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | , [0, ($vfs->{ext_private} | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ||= $vfs->default_ext_private)]) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 514 | my ($value, @ext) = @$desc; | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | 514 | $vfs->{_extdict}{$_} = $value for @ext; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 257 | ▶ | if ($spec) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 257 | my Folder $root = $vfs->root_create | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | (linsert($spec, 2, $vfs->cf_delegate(qw(entns)))); | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # Mark [data => ..] vfs as on_memory | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 257 | ▶ | $vfs->{_on_memory} = 1 if $spec->[0] eq 'data' or not $root->{path}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$spec->[0] eq "data" or not $root->{"path"}
MC/DC50%1/2
$spec->[0] eq "data" or not $root->{"path"}
$spec->[0] eq "data"
not $root->{"path"}
Truth table66%2/3
A or not(B)
A= $spec->[0] eq "data"B= not $root->{"path"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 257 | $$_[0]->($vfs, $$_[1]) for @task; | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 257 | $vfs->after_new; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | 252 | $vfs; | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 257 | ▶ | sub after_new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_new: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 257 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | 257 | ▶ | confess __PACKAGE__ . ": facade is empty!" unless $self->{facade}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 257 | weaken($self->{facade}); | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 257 | ▶ | $self->refresh_import if $self->{import}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 110 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 110 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | 110 | $self->{facade}->error(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 31 | ▶ | sub find_neighbor_file { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_neighbor_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 31 | (my VFS $vfs, my ($path)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | my VFS $other_vfs = $vfs->{facade}->find_neighbor_vfs | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 31 | (File::Basename::dirname($path)); | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | 31 | $other_vfs->find_file(File::Basename::basename($path)); | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 32 | ▶ | sub find_neighbor_type { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_neighbor_type: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 32 | (my VFS $vfs, my ($kind, $path)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 32 | ▶ | $kind //= -d $path ? 'dir' : 'file'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$kind //= -d $path ? "dir" : "file"
MC/DC0%0/1
$kind //= -d $path ? "dir" : "file"
$kind
Truth table50%1/2
A
A= $kind
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 32 | ▶ | if ($kind eq 'file') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 31 | $vfs->find_neighbor_file($path); | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | } elsif ($kind eq 'dir') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | $vfs->{facade}->find_neighbor($path); | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | croak "Unknown vfs type=$kind path=$path"; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub refresh_import { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refresh_import: not called CC=5 SCAR=30.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | (my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my Folder $root = $vfs->{_root}; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | my @files = grep { | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | -f $_ && defined $vfs->{_extdict}{extname($_)} | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
-f $_ && defined $vfs->{'_extdict'}{extname($_)}
MC/DC0%0/2
-f $_ && defined $vfs->{'_extdict'}{extname($_)}
-f $_
defined $vfs->{'_extdict'}{extname($_)}
Truth table0%0/3
A && B
A= -f $_B= defined $vfs->{'_extdict'}{extname($_)}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $fn = "$root->{path}/$_"; | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | 1 while $fn =~ s,/[^/\.]+/\.\./,/,g; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | glob($fn); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | } lexpand($vfs->{import}); | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | if (DEBUG_VFS) { | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | printf STDERR "# vfs-import to %s from %s (actually: %s)\n" | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | , $root->{path}, sorted_dump($vfs->{import}), sorted_dump(\@files); | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | foreach my $fn (@files) { | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my Folder $file = $vfs->find_neighbor_file($fn); | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # Skip if it exists. | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | next if $root->lookup_1($vfs, $file->{name}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | $root->{_Item}{$file->{name}} | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | = $vfs->create(file => $file->{path}, parent => $root | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | , imported => 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1032 | ▶ | sub find_file { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_file: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1032 | (my VFS $vfs, my $filename) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | # XXX: 拡張子をどうしたい? | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1032 | ▶ | my ($name) = $filename =~ m{^(\w+)} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | or croak "Can't extract part name from filename '$filename'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1032 | ▶ | my $nameSpec = length($name) == length($filename) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ? $name : [$name => $filename]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1032 | $vfs->{_root}->lookup($vfs, $nameSpec); | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub list_all_names { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_all_names: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | (my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $vfs->{_root}->list_all_names($vfs); | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | sub list_items { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_items: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | (my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | $vfs->{_root}->list_items($vfs); | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub list_base { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_base: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | (my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my Folder $folder = $_; # Actually, only folders can be a 'base'. | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $folder->{path}; | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | } $vfs->list_internal_base_folders; | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # XXX: Incontrast to list_items, list_internal_base_items returns internal VFS items | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub list_internal_base_folders { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_internal_base_folders: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | (my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $vfs->{_root}->list_base($vfs); | |||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 33 | ▶ | sub resolve_path_from { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_path_from: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 33 | (my VFS $vfs, my Folder $from, my $fn) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | # $fn usually comes from a decoded template string while paths are | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # octets in YATT. Joining a utf8-flagged string with an octet dirname | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # makes perl hand the utf8-encoded form to the filesystem. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 33 | ▶ | utf8::encode($fn) if utf8::is_utf8($fn); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 33 | my Folder $folder = $from->dirobj; | |||||||||||||||||||||||||||||||||||||||||||||
| 215 | 33 | ▶ | my $dirname = $folder->dirname | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 33 | my $abs = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | 33 | ▶ | if ($fn =~ /^@/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | $vfs->{facade}->app_path_expand($fn); | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | } elsif ($fn =~ s!^((?:\.\./)+)!!) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # leading upward relpath is treated specially. | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | my $up = length($1) / 3; | |||||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | my @dirs = File::Spec->splitdir($dirname); | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | File::Spec->catfile(@dirs[0.. $#dirs - $up], $fn); | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 30 | File::Spec->rel2abs($fn, $dirname); | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 33 | $abs; | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 50 | ▶ | sub find_part { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_part: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 50 | my VFS $vfs = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | 50 | $vfs->{_root}->lookup($vfs, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 616 | ▶ | sub find_part_from { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_part_from: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 616 | (my VFS $vfs, my $from) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | 616 | my Item $item = $from->lookup($vfs, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | 608 | ▶ | if ($item and $item->isa($vfs->Folder)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$item and $item->isa($vfs->Folder)
MC/DC100%2/2
$item and $item->isa($vfs->Folder)
$item
$item->isa($vfs->Folder)
Truth table100%3/3
A and B
A= $itemB= $item->isa($vfs->Folder)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 161 | (my Folder $folder = $item)->{_Item}{''} | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 447 | $item; | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub find_part_from_entns { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_part_from_entns: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | (my VFS $vfs, my $entns) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | my Folder $folder = $vfs->{entns2vfs_item}{$entns} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | or croak "Unknown entns $entns!"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $vfs->find_part_from($folder, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # kind 指定の part 検索 dispatcher。kind ごとの検索ロジック | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # (item-key の符号化を含む) は _find_kind_part__$kind として | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # subclass (YATT::Lite::Core) が定義する。GH-256 | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 154 | ▶ | sub find_kind_part_from { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_kind_part_from: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 154 | (my VFS $vfs, my ($from, $kind, $name)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | 154 | ▶ | my $sub = $vfs->can("_find_kind_part__$kind") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | or croak "Unknown part kind: $kind"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 153 | $sub->($vfs, $from, $name); | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # To limit call of refresh atmost 1, use this. | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 659 | ▶ | sub reset_refresh_mark { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_refresh_mark: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 659 | (my VFS $vfs) = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | 659 | ▶ | $vfs->{mark} = @_ ? shift : {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 9 | ▶ | sub re_ext { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
re_ext: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 9 | (my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | 18 | my $ext = join("|", grep {defined} | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | 9 | $vfs->{ext_public}, $vfs->{ext_private}); | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | 9 | qr{$ext}; | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1755 | ▶ | sub YATT::Lite::VFS::Folder::lookup { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1755 | print STDERR "# VFS: root->lookup(", sorted_dump(@_[2..$#_]), ")\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | if DEBUG_LOOKUP; | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 1755 | ▶ | $_[0]->lookup_1(@_[1..$#_]) | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$_[0]->lookup_1(@_[1 .. $#_]) // $_[0]->lookup_base(@_[1 .. $#_])
MC/DC100%2/2
$_[0]->lookup_1(@_[1 .. $#_]) // $_[0]->lookup_base(@_[1 .. $#_])
$_[0]->lookup_1(@_[1 .. $#_])
$_[0]->lookup_base(@_[1 .. $#_])
Truth table100%3/3
A // B
A= $_[0]->lookup_1(@_[1 .. $#_])B= $_[0]->lookup_base(@_[1 .. $#_])
| |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | // $_[0]->lookup_base(@_[1..$#_]) | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | sub YATT::Lite::VFS::Dir::dirobj { $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dirobj: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 33 | ▶ | sub YATT::Lite::VFS::File::dirobj { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dirobj: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 33 | (my vfs_file $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 287 | 33 | $file->{parent}; | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 33 | ▶ | sub YATT::Lite::VFS::Dir::dirname { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dirname: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 33 | (my vfs_dir $dir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 292 | 33 | $dir->{path}; | |||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub YATT::Lite::VFS::File::dirname { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dirname: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | (my vfs_file $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if (my $parent = $file->{parent}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $parent->dirname; | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | } elsif (my $path = $file->{path}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | File::Basename::dirname(File::Spec->rel2abs($path)); | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 78 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 576 | ▶ | sub YATT::Lite::VFS::File::fake_filename { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fake_filename: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 576 | (my vfs_file $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | 576 | ▶ | $file->{path} // $file->{name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$file->{"path"} // $file->{"name"}
MC/DC100%2/2
$file->{"path"} // $file->{"name"}
$file->{"path"}
$file->{"name"}
Truth table100%3/3
A // B
A= $file->{"path"}B= $file->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 549 | ▶ | sub YATT::Lite::VFS::File::lookup_1 { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_1: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 549 | (my vfs_file $file, my VFS $vfs, my $nameSpec) = splice @_, 0, 3; | |||||||||||||||||||||||||||||||||||||||||||||
| 313 | print STDERR "# VFS: $file->lookup_1(" | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 549 | , sorted_dump($nameSpec, @_), ") in (", sorted_dump($file->{path}), ")\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | if DEBUG_LOOKUP; | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 549 | ▶ | unless (@_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # ファイルの中には、深さ 1 の name しか無いはずだから。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # mtime, refresh | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 518 | ▶ | $file->refresh($vfs) unless $vfs->{mark}{refaddr($file)}++; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 518 | my ($name) = lexpand($nameSpec); | |||||||||||||||||||||||||||||||||||||||||||||
| 321 | 518 | my Item $item = $file->{_Item}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | # import alias はここでソース側 Part へ解決する。GH-256 | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # (data vfs では _Item に生の文字列等も入りうるので Item の時だけ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 518 | ▶ | return $item->resolve_alias($vfs) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$item and ref $item and UNIVERSAL::isa($item, "YATT::Lite::VFS::Item")
$item and ref $item
MC/DC66%2/3
$item and ref $item and UNIVERSAL::isa($item, "YATT::Lite::VFS::Item")
$item
ref $item
UNIVERSAL::isa($item, "YATT::Lite::VFS::Item")
Truth table75%3/4
A and B and C
A= $itemB= ref $itemC= UNIVERSAL::isa($item, "YATT::Lite::VFS::Item")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | if $item and ref $item and UNIVERSAL::isa($item, Item); | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 159 | ▶ | return $item if $item; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 170 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1442 | ▶ | sub YATT::Lite::VFS::Dir::lookup_1 { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_1: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1442 | (my vfs_dir $dir, my VFS $vfs, my $nameSpec) = splice @_, 0, 3; | |||||||||||||||||||||||||||||||||||||||||||||
| 332 | print STDERR "# VFS: $dir->lookup_1(" | ||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 1442 | , sorted_dump($nameSpec, @_), ") in (", sorted_dump($dir->{path}), ")\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 334 | if DEBUG_LOOKUP; | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1442 | ▶ | if (my Item $item = $dir->cached_in | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$dir->{"_Item"} //= {}
MC/DC100%1/1
$dir->{"_Item"} //= {}
$dir->{"_Item"}
Truth table100%2/2
A
A= $dir->{"_Item"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | ($dir->{_Item} //= {}, $nameSpec, $vfs, $vfs->{mark})) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 1096 | ▶ | if ((not ref $item or not UNIVERSAL::isa($item, Item)) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
ref $item and UNIVERSAL::isa($item, "YATT::Lite::VFS::Item") or $vfs->{"no_auto_create"}
ref $item and UNIVERSAL::isa($item, "YATT::Lite::VFS::Item")
MC/DC100%3/3
ref $item and UNIVERSAL::isa($item, "YATT::Lite::VFS::Item") or $vfs->{"no_auto_create"}
ref $item
UNIVERSAL::isa($item, "YATT::Lite::VFS::Item")
$vfs->{"no_auto_create"}
Truth table100%5/5
A and B or C
A= ref $itemB= UNIVERSAL::isa($item, "YATT::Lite::VFS::Item")C= $vfs->{"no_auto_create"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | and not $vfs->{no_auto_create}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # Special case (mostly for test) | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # data vfs can contain vfs spec (string, array, hash). | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 248 | my ($name) = lexpand($nameSpec); | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | 248 | $item = $dir->{_Item}{$name} = $vfs->create | |||||||||||||||||||||||||||||||||||||||||||||
| 343 | (data => $item, parent => $dir, name => $name); | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 1086 | ▶ | return $item unless @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 51 | ▶ | if (not $vfs->{no_mro_c3} and $dir->{entns}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $vfs->{"no_mro_c3"} and $dir->{"entns"}
MC/DC50%1/2
not $vfs->{"no_mro_c3"} and $dir->{"entns"}
not $vfs->{"no_mro_c3"}
$dir->{"entns"}
Truth table66%2/3
not(A) and B
A= not $vfs->{"no_mro_c3"}B= $dir->{"entns"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 25 | $item = $item->lookup_1($vfs, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 348 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 26 | $item = $item->lookup($vfs, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 51 | ▶ | return $item if $item; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 326 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 373 | ▶ | sub YATT::Lite::VFS::Folder::lookup_base { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_base: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 373 | (my Folder $item, my VFS $vfs, my $nameSpec) = splice @_, 0, 3; | |||||||||||||||||||||||||||||||||||||||||||||
| 357 | print STDERR "# VFS: $item->lookup_base(" | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 373 | , sorted_dump($item->{path}) ,")(", sorted_dump($nameSpec, @_), ")\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 359 | if DEBUG_LOOKUP; | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 373 | ▶ | if (not $vfs->{no_mro_c3} and $item->{entns}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $vfs->{"no_mro_c3"} and $item->{"entns"}
MC/DC50%1/2
not $vfs->{"no_mro_c3"} and $item->{"entns"}
not $vfs->{"no_mro_c3"}
$item->{"entns"}
Truth table66%2/3
not(A) and B
A= not $vfs->{"no_mro_c3"}B= $item->{"entns"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 346 | (undef, my @super_ns) = @{mro::get_linear_isa($item->{entns})}; | |||||||||||||||||||||||||||||||||||||||||||||
| 363 | my @super = map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 346 | ▶ | my $o = $vfs->{entns2vfs_item}{$_}; $o ? $o : () | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } @super_ns; | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 346 | foreach my $super (@super) { | |||||||||||||||||||||||||||||||||||||||||||||
| 367 | 196 | ▶ | my $ans = $super->lookup_1($vfs, $nameSpec, @_) or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 73 | return $ans; | |||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 27 | my @super = $item->list_base; | |||||||||||||||||||||||||||||||||||||||||||||
| 372 | 27 | foreach my $super (@super) { | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | 26 | ▶ | my $ans = $super->lookup($vfs, $nameSpec, @_) or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 21 | return $ans; | |||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 279 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 1819 | ▶ | sub YATT::Lite::VFS::Folder::list_base { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_base: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 1819 | ▶ | my Folder $folder = shift; @{$folder->{base} ||= []} | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$folder->{"base"} ||= []
MC/DC100%1/1
$folder->{"base"} ||= []
$folder->{"base"}
Truth table100%2/2
A
A= $folder->{"base"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 1799 | ▶ | sub YATT::Lite::VFS::File::list_base { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_base: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 1799 | my vfs_file $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # $dir/$file.yatt inherits its own base decl, | ||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 1799 | my (@local, @otherdir); | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | 1799 | foreach my Folder $super ($file->YATT::Lite::VFS::Folder::list_base) { | |||||||||||||||||||||||||||||||||||||||||||||
| 388 | 69 | ▶ | if ($super->{parent} and $file->{parent} == $super->{parent}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$super->{"parent"} and $file->{"parent"} == $super->{"parent"}
MC/DC100%2/2
$super->{"parent"} and $file->{"parent"} == $super->{"parent"}
$super->{"parent"}
$file->{"parent"} == $super->{"parent"}
Truth table100%3/3
A and B
A= $super->{"parent"}B= $file->{"parent"} == $super->{"parent"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 46 | push @local, $super; | |||||||||||||||||||||||||||||||||||||||||||||
| 390 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 23 | push @otherdir, $super; | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1799 | push @local, grep {$_} $file->{parent}, $file->{overlay}; | |||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 1799 | ▶ | if ($file->{entns} and mro::get_mro($file->{entns}) eq 'c3') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$file->{"entns"} and &mro::get_mro($file->{"entns"}) eq "c3"
MC/DC50%1/2
$file->{"entns"} and &mro::get_mro($file->{"entns"}) eq "c3"
$file->{"entns"}
&mro::get_mro($file->{"entns"}) eq "c3"
Truth table66%2/3
A and B
A= $file->{"entns"}B= &mro::get_mro($file->{"entns"}) eq "c3"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | print STDERR "use c3 for $file->{entns}" | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | , "\n ".sorted_dump([local => map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | my Folder $f = $_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | mro::get_linear_isa($f->{entns}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } @local]) | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | , "\n ".sorted_dump([other => map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1783 | my Folder $f = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 405 | mro::get_linear_isa($f->{entns}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } @otherdir]) | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | , "\n" if DEBUG_MRO; | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 1783 | return (@local, @otherdir); | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 16 | print STDERR "use dfs for $file->{entns}\n" if DEBUG_MRO; | |||||||||||||||||||||||||||||||||||||||||||||
| 411 | 16 | return (@otherdir, @local); | |||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | sub YATT::Lite::VFS::File::list_items { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_items: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | croak "NIMPL"; | |||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 9 | ▶ | sub YATT::Lite::VFS::Dir::list_all_names { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_all_names: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 9 | (my vfs_dir $in, my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 419 | 9 | ▶ | croak "BUG: vfs is undef!" unless defined $vfs; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 9 | ▶ | return unless defined $in->{path}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 9 | my (@names, %seen); | |||||||||||||||||||||||||||||||||||||||||||||
| 422 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 78 | ▶ | use 5.012; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 9 | my $extRe = $vfs->re_ext; | |||||||||||||||||||||||||||||||||||||||||||||
| 425 | 9 | local $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 426 | 9 | opendir my $dh, "$in->{path}/"; | |||||||||||||||||||||||||||||||||||||||||||||
| 427 | 9 | ▶ | while (readdir $dh) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 33 | ▶ | /^(\w+)(?:\.$extRe)?\z/ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 15 | ▶ | next if $seen{$1}++; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 15 | push @names, $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 9 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 9 | @names; | |||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 2 | ▶ | sub YATT::Lite::VFS::Dir::list_items { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_items: called CC=6 SCAR=19.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 2 | (my vfs_dir $in, my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 439 | 2 | ▶ | croak "BUG: vfs is undef!" unless defined $vfs; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 2 | ▶ | return unless defined $in->{path}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | my %dup; | |||||||||||||||||||||||||||||||||||||||||||||
| 442 | my @exts = map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 4 | ▶ | if (defined $_ and not $dup{$_}++) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_ and not $dup{$_}++
MC/DC0%0/2
defined $_ and not $dup{$_}++
defined $_
not $dup{$_}++
Truth table33%1/3
A and not(B)
A= defined $_B= not $dup{$_}++
| |||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 4 | $_ | |||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | } else { () } | |||||||||||||||||||||||||||||||||||||||||||||
| 446 | 2 | } ($vfs->{ext_public}, $vfs->{ext_private}); | |||||||||||||||||||||||||||||||||||||||||||||
| 447 | 2 | my %dup2; | |||||||||||||||||||||||||||||||||||||||||||||
| 448 | map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2 | my $name = substr($_, length($in->{path})+1); | |||||||||||||||||||||||||||||||||||||||||||||
| 450 | 3 | $name =~ s/\.\w+$//; | |||||||||||||||||||||||||||||||||||||||||||||
| 451 | 3 | ▶ | $dup2{$name}++ ? () : $name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | # Not CORE::glob: it splits the pattern on whitespace in the path. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } File::Glob::bsd_glob("$in->{path}/[a-z]*.{".join(",", @exts)."}"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 455 | #---------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 463 | ▶ | sub YATT::Lite::VFS::Dir::load { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=15 SCAR=27.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 463 | (my vfs_dir $in, my VFS $vfs, my $nameSpec) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | 463 | ▶ | return unless defined $in->{path}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 439 | print STDERR "# VFS: Dir::load(", sorted_dump($nameSpec), ") in $in\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 460 | if DEBUG_LOOKUP; | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 439 | my ($partName, $realFile) = lexpand($nameSpec); | |||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # When $partName contains NUL like 'do\0action', | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | # we should avoid filesystem testings. | ||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 439 | ▶ | if ($partName =~ /\0/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 21 | print STDERR "# VFS: -> avoid fs lookup for \\0 in $in\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | if DEBUG_LOOKUP; | ||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 21 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | # A (part) name must never escape $in->{path}. Request-derived names | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # are already restricted to \w+ in WebMVC0::Connection; this is the | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | # last line of defense for every other caller. | ||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 418 | foreach my $n ($partName, $realFile) { | |||||||||||||||||||||||||||||||||||||||||||||
| 475 | 832 | ▶ | next unless defined $n; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 623 | ▶ | if ($n =~ m{/} or $n =~ m{\.\.}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$n =~ m[/] or $n =~ /\.\./
MC/DC100%2/2
$n =~ m[/] or $n =~ /\.\./
$n =~ m[/]
$n =~ /\.\./
Truth table100%3/3
A or B
A= $n =~ m[/]B= $n =~ /\.\./
| |||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 4 | croak "Invalid part name (contains '/' or '..'): $n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 414 | ▶ | $realFile ||= $partName; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$realFile ||= $partName
MC/DC0%0/2
$realFile ||= $partName
$realFile
$partName
Truth table66%2/3
A ||= B
A= $realFileB= $partName
| |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | # Template-derived names are decoded strings; paths are octets. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 414 | ▶ | utf8::encode($realFile) if utf8::is_utf8($realFile); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 414 | my $vfsname = "$in->{path}/$realFile"; | |||||||||||||||||||||||||||||||||||||||||||||
| 486 | 414 | my @opt = (name => $partName, parent => $in); | |||||||||||||||||||||||||||||||||||||||||||||
| 487 | 414 | my ($kind, $path, @other) = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 488 | 414 | ▶ | if (ref $nameSpec) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 205 | my $ext = extname($vfsname); | |||||||||||||||||||||||||||||||||||||||||||||
| 490 | (file => $vfsname | ||||||||||||||||||||||||||||||||||||||||||||||
| 491 | , ($ext eq $vfs->{ext_public} | ||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 205 | ▶ | ? (public => 1) : ())); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } elsif (my $fn = $vfs->find_ext($vfsname, $vfs->{ext_public})) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 126 | (file => $fn, public => 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 495 | } elsif ($fn = $vfs->find_ext($vfsname, $vfs->{ext_private})) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # dir の場合、 new_tmplpkg では? | ||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 21 | ▶ | my $kind = -d $fn ? 'dir' : 'file'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 21 | ($kind => $fn); | |||||||||||||||||||||||||||||||||||||||||||||
| 499 | } elsif (-d $vfsname) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 1 | return $vfs->{facade}->find_neighbor($vfsname); | |||||||||||||||||||||||||||||||||||||||||||||
| 501 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 61 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 504 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 352 | $vfs->create($kind, $path, @opt, @other); | |||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 292 | ▶ | sub find_ext { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_ext: called CC=5 SCAR=16.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 292 | (my VFS $vfs, my ($vfsname, $spec)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 509 | 292 | ▶ | foreach my $ext (!defined $spec ? () : ref $spec ? @$spec : $spec) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 292 | my $fn = "$vfsname.$ext"; | |||||||||||||||||||||||||||||||||||||||||||||
| 511 | 292 | ▶ | return $fn if -e $fn; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 514 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 515 | # 実験用、ダミーのパーサー | ||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 644 | ▶ | sub YATT::Lite::VFS::File::reset { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 644 | (my File $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 518 | 644 | undef $file->{_partlist}; | |||||||||||||||||||||||||||||||||||||||||||||
| 519 | 644 | undef $file->{_boundarylist}; | |||||||||||||||||||||||||||||||||||||||||||||
| 520 | 644 | undef $file->{_Item}; | |||||||||||||||||||||||||||||||||||||||||||||
| 521 | # undef $file->{string}; | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 644 | undef $file->{base}; | |||||||||||||||||||||||||||||||||||||||||||||
| 523 | 644 | $file->{_dependency} = +{}; | |||||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 2 | ▶ | sub YATT::Lite::VFS::Dir::refresh {} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refresh: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 23 | ▶ | sub YATT::Lite::VFS::File::refresh { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refresh: called CC=8 SCAR=21.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 23 | (my vfs_file $file, my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 528 | 23 | ▶ | return unless $$file{path} || $$file{string}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$file->{"path"} or $file->{"string"}
MC/DC0%0/2
$file->{"path"} or $file->{"string"}
$file->{"path"}
$file->{"string"}
Truth table66%2/3
A or B
A= $file->{"path"}B= $file->{"string"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # XXX: mtime! | ||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 23 | my @part = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 531 | 23 | local $/; split /^!\s*(\w+)\s+(\S+)[^\n]*?\n/m, do { | |||||||||||||||||||||||||||||||||||||||||||||
| 532 | 23 | ▶ | if ($$file{path}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 533 | open my $fh, '<', $$file{path} | ||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 20 | ▶ | or die "Can't open '$$file{path}': $!"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 535 | scalar <$fh> | ||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 20 | } else { | |||||||||||||||||||||||||||||||||||||||||||||
| 537 | 3 | $$file{string}; | |||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 539 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 540 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 23 | $file->add_widget('', shift @part); | |||||||||||||||||||||||||||||||||||||||||||||
| 542 | 23 | ▶ | while (my ($kind, $name, $part) = splice @part, 0, 3) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 19 | ▶ | if (defined $kind and my $sub = $file->can("declare_$kind")) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $kind and my $sub = $file->can("declare_$kind")
MC/DC50%1/2
defined $kind and my $sub = $file->can("declare_$kind")
defined $kind
my $sub = $file->can("declare_$kind")
Truth table66%2/3
A and B
A= defined $kindB= my $sub = $file->can("declare_$kind")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 4 | $sub->($file, $name, $vfs, $part); | |||||||||||||||||||||||||||||||||||||||||||||
| 545 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 15 | $file->can("add_$kind")->($file, $name, $part); | |||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 87 | ▶ | sub YATT::Lite::VFS::File::add_dependency { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_dependency: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 87 | (my File $file, my $wpath, my File $other) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 553 | 87 | Scalar::Util::weaken($file->{_dependency}{$wpath} = $other); | |||||||||||||||||||||||||||||||||||||||||||||
| 554 | 87 | ▶ | $other->add_dependent($file) if UNIVERSAL::isa($other, File); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 86 | ▶ | sub YATT::Lite::VFS::File::add_dependent { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_dependent: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 86 | (my File $file, my File $other) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 558 | 86 | Scalar::Util::weaken($file->{_dependents}{refaddr($other)} = $other); | |||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 580 | ▶ | sub YATT::Lite::VFS::File::list_dependents { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_dependents: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 580 | (my File $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 562 | defined (my $deps = $file->{_dependents}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 580 | ▶ | or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 3 | grep {defined} values %$deps; | |||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 496 | ▶ | sub YATT::Lite::VFS::File::list_dependency { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_dependency: called CC=4 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 496 | (my File $file, my $detail) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 568 | defined (my $deps = $file->{_dependency}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 496 | ▶ | or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 496 | ▶ | if ($detail) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | wantarray ? map([$_ => $deps->{$_}], keys %$deps) : $deps; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 496 | values %$deps; | |||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 496 | ▶ | sub refresh_deps_for { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refresh_deps_for: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 496 | (my MY $self, my File $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 578 | 496 | print STDERR "refresh deps for: ", $file->{path}, "\n" if DEBUG_REBUILD; | |||||||||||||||||||||||||||||||||||||||||||||
| 579 | 496 | foreach my $dep ($file->list_dependency) { | |||||||||||||||||||||||||||||||||||||||||||||
| 580 | 133 | ▶ | unless ($self->{mark}{refaddr($dep)}++) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 108 | print STDERR " refreshing: ", $dep->{path}, "\n" if DEBUG_REBUILD; | |||||||||||||||||||||||||||||||||||||||||||||
| 582 | 108 | $dep->refresh($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||
| 587 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 26 | ▶ | sub add_to { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_to: called CC=4 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 26 | (my VFS $vfs, my ($path, $data)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 590 | 26 | ▶ | my @path = ref $path ? @$path : $path; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 26 | my $lastName = pop @path; | |||||||||||||||||||||||||||||||||||||||||||||
| 592 | 26 | my Folder $folder = $vfs->{_root}; | |||||||||||||||||||||||||||||||||||||||||||||
| 593 | 26 | ▶ | while (@path) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my $name = shift @path; | |||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | $folder = $folder->{_Item}{$name} ||= $vfs->create | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$folder->{"_Item"}{$name} ||= $vfs->create("data", {}, "name", $name, "parent", $folder)
MC/DC0%0/2
$folder->{"_Item"}{$name} ||= $vfs->create("data", {}, "name", $name, "parent", $folder)
$folder->{"_Item"}{$name}
$vfs->create("data", {}, "name", $name, "parent", $folder)
Truth table0%0/3
A ||= B
A= $folder->{"_Item"}{$name}B= $vfs->create("data", {}, "name", $name, "parent", $folder)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 596 | (data => {}, name => $name, parent => $folder); | ||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 598 | # XXX: path を足すと、memory 動作の時に困る | ||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 26 | my Item $item = $vfs->create | |||||||||||||||||||||||||||||||||||||||||||||
| 600 | (data => $data, name => $lastName, parent => $folder); | ||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 21 | $folder->{_Item}{$item->item_key} = $item; | |||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 603 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 51 | ▶ | sub root {(my VFS $vfs) = @_; $vfs->{_root}} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
root: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||
| 606 | # special hook for root creation. | ||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 257 | ▶ | sub root_create { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
root_create: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 257 | (my VFS $vfs, my ($kind, $primary, %rest)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 609 | 257 | ▶ | $rest{entns} //= $vfs->{entns}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$rest{"entns"} //= $vfs->{"entns"}
MC/DC50%1/2
$rest{"entns"} //= $vfs->{"entns"}
$rest{"entns"}
$vfs->{"entns"}
Truth table66%2/3
A //= B
A= $rest{"entns"}B= $vfs->{"entns"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 257 | $vfs->{_root} = $vfs->create($kind, $primary, %rest); | |||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 893 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 893 | (my VFS $vfs, my ($kind, $primary, %rest)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 614 | # XXX: $vfs は className の時も有る。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 893 | ▶ | if (my $sub = $vfs->can("create_$kind")) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 652 | $vfs->fixup_created(\@_, $sub->($vfs, $primary, %rest, type => $kind)); | |||||||||||||||||||||||||||||||||||||||||||||
| 617 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 241 | ▶ | $vfs->{cache}{$primary} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$vfs->{"cache"}{$primary} ||= do {
$rest{"entns"} //= $vfs->{"entns"};
$vfs->fixup_created(\@_, $vfs->can("vfs_$kind")->()->new(%rest, "path", $primary, "type", $kind))
}
MC/DC0%0/2
$vfs->{"cache"}{$primary} ||= do {
$rest{"entns"} //= $vfs->{"entns"};
$vfs->fixup_created(\@_, $vfs->can("vfs_$kind")->()->new(%rest, "path", $primary, "type", $kind))
}
$vfs->{"cache"}{$primary}
do {
$rest{"entns"} //= $vfs->{"entns"};
$vfs->fixup_created(\@_, $vfs->can("vfs_$kind")->()->new(%rest, "path", $primary, "type", $kind))
}
Truth table33%1/3
A ||= B
A= $vfs->{"cache"}{$primary}B= do {
$rest{"entns"} //= $vfs->{"entns"};
$vfs->fixup_created(\@_, $vfs->can("vfs_$kind")->()->new(%rest, "path", $primary, "type", $kind))
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 619 | # XXX: Really?? | ||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 241 | ▶ | $rest{entns} //= $vfs->{entns}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$rest{"entns"} //= $vfs->{"entns"}
MC/DC50%1/2
$rest{"entns"} //= $vfs->{"entns"}
$rest{"entns"}
$vfs->{"entns"}
Truth table66%2/3
A //= B
A= $rest{"entns"}B= $vfs->{"entns"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 241 | $vfs->fixup_created | |||||||||||||||||||||||||||||||||||||||||||||
| 622 | (\@_, $vfs->can("vfs_$kind")->()->new(%rest, path => $primary | ||||||||||||||||||||||||||||||||||||||||||||||
| 623 | , type => $kind | ||||||||||||||||||||||||||||||||||||||||||||||
| 624 | )); | ||||||||||||||||||||||||||||||||||||||||||||||
| 625 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | sub sorted_dump { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sorted_dump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||||||
| 630 | join ", ", map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | Data::Dumper->new([$_])->Maxdepth(2)->Terse(1)->Indent(0) | |||||||||||||||||||||||||||||||||||||||||||||
| 632 | ->Sortkeys(1)->Dump; | ||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 893 | ▶ | sub fixup_created { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fixup_created: called CC=10 SCAR=23.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 893 | (my VFS $vfs, my $info, my Folder $folder) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 637 | 893 | if (DEBUG_VFS) { | |||||||||||||||||||||||||||||||||||||||||||||
| 638 | printf STDERR "# VFS::create(%s) => %s(0x%x)\n" | ||||||||||||||||||||||||||||||||||||||||||||||
| 639 | , sorted_dump(@{$info}[1..$#$info]) | ||||||||||||||||||||||||||||||||||||||||||||||
| 640 | , ref $folder, ($folder+0); | ||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } elsif (DEBUG_LOOKUP) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 642 | print STDERR "# VFS: created: $folder (path=" | ||||||||||||||||||||||||||||||||||||||||||||||
| 643 | , sorted_dump($folder->{path}), ")\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 645 | # XXX: This is required for perl 5.18 and before. | ||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 647 | # create の直後、 after_create より前に、mark を打つ。そうしないと、 delegate で困る。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 893 | ▶ | if (ref $vfs) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 891 | $vfs->{_n_creates}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 650 | 891 | $vfs->{mark}{refaddr($folder)}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 893 | ▶ | if (my $path = $folder->{path} and not defined $folder->{name}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
my $path = $folder->{"path"} and not defined $folder->{"name"}
MC/DC100%2/2
my $path = $folder->{"path"} and not defined $folder->{"name"}
my $path = $folder->{"path"}
not defined $folder->{"name"}
Truth table100%3/3
A and not(B)
A= my $path = $folder->{"path"}B= not defined $folder->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 224 | $path =~ s/\.\w+$//; | |||||||||||||||||||||||||||||||||||||||||||||
| 655 | 224 | $path =~ s!.*/!!; | |||||||||||||||||||||||||||||||||||||||||||||
| 656 | 224 | $folder->{name} = $path; | |||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 893 | ▶ | if (my Folder $parent = $folder->{parent}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 626 | ▶ | if (defined $parent->{entns}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 661 | $folder->{entns} = join '::' | ||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 605 | , $parent->{entns}, $folder->{name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 663 | # XXX: base 指定だけで済むべきだが、Factory を呼んでないので出来ないorz... | ||||||||||||||||||||||||||||||||||||||||||||||
| 664 | YATT::Lite::MFields->add_isa_to | ||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 605 | ($folder->{entns}, $parent->{entns}); | |||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 893 | ▶ | if ($folder->{entns}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 847 | ▶ | if (not $vfs->{no_mro_c3}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 847 | mro::set_mro($folder->{entns}, 'c3'); | |||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 847 | ▶ | if (defined (my Folder $old = $vfs->{entns2vfs_item}{$folder->{entns}})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | if ($old != $folder) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | croak "EntNS confliction for $folder->{entns}! old=$old->{path} vs new=$folder->{path}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 847 | $vfs->{entns2vfs_item}{$folder->{entns}} = $folder; | |||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 893 | $folder->after_create($vfs); | |||||||||||||||||||||||||||||||||||||||||||||
| 680 | 861 | $folder; | |||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||
| 683 | # XXX: <=> find_part_from_entns | ||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 3 | ▶ | sub find_template_from_package { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_template_from_package: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 3 | (my MY $self, my $pkg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 686 | 3 | $self->{entns2vfs_item}{$pkg}; | |||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 317 | ▶ | sub create_data { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_data: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 317 | (my VFS $vfs, my ($primary)) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 691 | 317 | ▶ | if (ref $primary) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 692 | # 直接 Folder slot にデータを。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 41 | my vfs_dir $item = $vfs->vfs_dir->new(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 694 | 41 | $item->{_Item} = $primary; | |||||||||||||||||||||||||||||||||||||||||||||
| 695 | 41 | $item; | |||||||||||||||||||||||||||||||||||||||||||||
| 696 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 276 | $vfs->vfs_file->new(public => 1, @_, string => $primary); | |||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||
| 701 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 702 | # This converts all descriptors in Folder->base into real item objects. | ||||||||||||||||||||||||||||||||||||||||||||||
| 703 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 262 | ▶ | sub YATT::Lite::VFS::Folder::vivify_base_descs { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vivify_base_descs: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 262 | (my Folder $folder, my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 706 | 262 | foreach my Folder $desc (@{$folder->{base}}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 707 | 51 | ▶ | if (ref $desc eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 708 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 709 | # This $desc structure *may* come from Factory->_list_base_spec_in | ||||||||||||||||||||||||||||||||||||||||||||||
| 710 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 51 | ▶ | if ($desc->[0] eq 'dir') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 712 | # To create YATT::Lite with .htyattconfig.xhf, Factory should be involved. | ||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 47 | $desc = $vfs->{facade}->find_neighbor($desc->[1]); | |||||||||||||||||||||||||||||||||||||||||||||
| 714 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 4 | $desc = $vfs->create(@$desc); | |||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # parent がある == parent から指されている。なので、 weaken する必要が有る。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 51 | ▶ | weaken($desc) if $desc->{parent}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 262 | ▶ | sub YATT::Lite::VFS::Dir::after_create { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_create: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 262 | (my vfs_dir $dir, my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 724 | 262 | $dir->YATT::Lite::VFS::Folder::vivify_base_descs($vfs); | |||||||||||||||||||||||||||||||||||||||||||||
| 725 | # $dir->refresh($vfs); | ||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 262 | $dir; | |||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 728 | # file 系は create 時に必ず refresh. refresh は decl のみ parse. | ||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 631 | ▶ | sub YATT::Lite::VFS::File::after_create { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_create: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 631 | (my vfs_file $file, my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 731 | 631 | $file->refresh_overlay($vfs); | |||||||||||||||||||||||||||||||||||||||||||||
| 732 | 631 | $file->refresh($vfs); | |||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 631 | ▶ | sub YATT::Lite::VFS::File::refresh_overlay { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refresh_overlay: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 631 | (my vfs_file $file, my VFS $vfs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 736 | 631 | ▶ | return if $file->{overlay}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 631 | ▶ | return unless $file->{path}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 355 | my $rootname = rootname($file->{path}); | |||||||||||||||||||||||||||||||||||||||||||||
| 739 | 355 | my @found = grep {-d $$_[-1]} ([1, $rootname] | |||||||||||||||||||||||||||||||||||||||||||||
| 740 | , [0, "$rootname.$vfs->{ext_private}"]); | ||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 355 | ▶ | if (@found > 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 742 | $vfs->error(q|Don't use %1$s and %1$s.%2$s at once| | ||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | , $rootname, $vfs->{ext_private}); | |||||||||||||||||||||||||||||||||||||||||||||
| 744 | } elsif (not @found) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 354 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 1 | $file->{overlay} = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 748 | 1 | my ($public, $path) = @{$found[0]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 749 | 1 | ▶ | if ($public) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 1 | $vfs->{facade}->find_neighbor($path); | |||||||||||||||||||||||||||||||||||||||||||||
| 751 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 752 | $vfs->create | ||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | (dir => $path, parent => $file->{parent}); | |||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 755 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 757 | #---------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 4 | ▶ | sub YATT::Lite::VFS::File::declare_base { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
declare_base: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 4 | (my vfs_file $file, my ($spec), my VFS $vfs, my $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 760 | 4 | my ($kind, $path) = split /=/, $spec, 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 761 | # XXX: 物理 path だと困るよね? findINC 的な処理が欲しい | ||||||||||||||||||||||||||||||||||||||||||||||
| 762 | # XXX: 帰属ディレクトリより強くするため、先頭に。でも、不満。 | ||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 4 | unshift @{$file->{base}}, $vfs->create($kind => $path); | |||||||||||||||||||||||||||||||||||||||||||||
| 764 | 4 | weaken($file->{base}[0]); | |||||||||||||||||||||||||||||||||||||||||||||
| 765 | 4 | $file->{_Item}{''} .= $part; | |||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 38 | ▶ | sub YATT::Lite::VFS::File::add_widget { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_widget: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 38 | (my vfs_file $file, my ($name, $part)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 769 | 38 | push @{$file->{_partlist}}, $file->{_Item}{$name} = $part; | |||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 257 | ▶ | sub linsert { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
linsert: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 257 | my @ls = @{shift()}; | |||||||||||||||||||||||||||||||||||||||||||||
| 774 | 257 | splice @ls, shift, 0, @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 775 | 257 | ▶ | wantarray ? @ls : \@ls; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 78 | ▶ | use YATT::Lite::Breakpoint; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 78 | YATT::Lite::Breakpoint::break_load_vfs(); | |||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 78 | 1; | |||||||||||||||||||||||||||||||||||||||||||||