| 1 | 5 | ▶ | use strict; use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | package IO::All::Link; | ||||||||||
| 3 | |||||||||||
| 4 | 5 | ▶ | use IO::All::File -base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 5 | const type => 'link'; | |||||||||
| 7 | |||||||||||
| 8 | sub link { | ||||||||||
| 9 | 9 | ▶ | my $self = shift; | ||||||||
|
Subroutine
link: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 10 | 9 | bless $self, __PACKAGE__; | |||||||||
| 11 | 9 | ▶ | $self->name(shift) if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 9 | $self->_init; | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | sub readlink { | ||||||||||
| 16 | 3 | ▶ | my $self = shift; | ||||||||
|
Subroutine
readlink: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 17 | 3 | $self->_constructor->(CORE::readlink($self->name)); | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | sub symlink { | ||||||||||
| 21 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
symlink: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 22 | 0 | my $target = shift; | |||||||||
| 23 | 0 | ▶ | $self->assert_filepath if $self->_assert; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | CORE::symlink($target, $self->pathname); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | sub AUTOLOAD { | ||||||||||
| 28 | 2 | ▶ | my $self = shift; | ||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=7.5
| |||||||||||
| 29 | 2 | our $AUTOLOAD; | |||||||||
| 30 | 2 | (my $method = $AUTOLOAD) =~ s/.*:://; | |||||||||
| 31 | 2 | my $target = $self->target; | |||||||||
| 32 | 2 | ▶ | unless ($target) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | $self->throw("Can't call $method on symlink"); | |||||||||
| 34 | 0 | return; | |||||||||
| 35 | } | ||||||||||
| 36 | 2 | $target->$method(@_); | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | sub target { | ||||||||||
| 40 | 2 | ▶ | my $self = shift; | ||||||||
|
Subroutine
target: called CC=8 SCAR=25.1
Pod
undocumented
| |||||||||||
| 41 | 2 | ▶ | return *$self->{target} if *$self->{target}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 1 | my %seen; | |||||||||
| 43 | 1 | my $link = $self; | |||||||||
| 44 | 1 | my $new; | |||||||||
| 45 | 1 | ▶ | while ($new = $link->readlink) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 1 | ▶ | my $type = $new->type or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 1 | ▶ | last if $type eq 'file'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 1 | ▶ | last if $type eq 'dir'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 0 | ▶ | return unless $type eq 'link'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | ▶ | return if $seen{$new->name}++; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 0 | $link = $new; | |||||||||
| 52 | } | ||||||||||
| 53 | 1 | *$self->{target} = $new; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub exists { -l shift->pathname } | ||||||||
|
Subroutine
exists: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 57 | |||||||||||
| 58 | 5 | 1; | |||||||||