| 1 | package File::Symlink::Relative; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.008001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | # OK, the following is probably paranoia. But if Perl 7 decides to | ||||||||||||||||||||||||||||
| 9 | # change this particular default I'm ready. Unless they eliminate $]. | ||||||||||||||||||||||||||||
| 10 | 2 | ▶ | no if $] ge '5.020', feature => qw{ signatures }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Exporter qw{ import }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | our $VERSION = '0.005_01'; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | our @EXPORT_OK = qw{ | |||||||||||||||||||||||||||
| 19 | symlink_r | ||||||||||||||||||||||||||||
| 20 | SYMLINK_SUPPORTED | ||||||||||||||||||||||||||||
| 21 | }; | ||||||||||||||||||||||||||||
| 22 | 2 | our @EXPORT = qw{ symlink_r }; ## no critic (ProhibitAutomaticExportation) | |||||||||||||||||||||||||||
| 23 | 2 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||
| 24 | all => \@EXPORT_OK, | ||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | { | ||||||||||||||||||||||||||||
| 28 | 2 | local $@ = undef; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | # This is true if and only if symbolic links are supported by the | ||||||||||||||||||||||||||||
| 31 | # underlying operating system. The check is from | ||||||||||||||||||||||||||||
| 32 | # perldoc -f symlink | ||||||||||||||||||||||||||||
| 33 | # in Perl 5.30.2. | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 2 | ▶ | use constant SYMLINK_SUPPORTED => eval { symlink '', ''; 1 } || 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.0
Condition50%1/2
eval {
do {
symlink '', '';
1
}
} || 0
MC/DC0%0/1
eval {
do {
symlink '', '';
1
}
} || 0
eval {
do {
symlink '', '';
1
}
}
Truth table50%1/2
A
A= eval {
do {
symlink '', '';
1
}
}
| |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 2 | sub symlink_r ($$) { ## no critic (ProhibitSubroutinePrototypes) | |||||||||||||||||||||||||||
| 39 | 1 | ▶ | my ( $source, $target ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
symlink_r: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 1 | my ( $tgt_device, $tgt_dir ) = File::Spec->splitpath( $target ); | |||||||||||||||||||||||||||
| 41 | 1 | ▶ | defined $tgt_device | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $tgt_device and "" ne $tgt_device
MC/DC0%0/2
defined $tgt_device and "" ne $tgt_device
defined $tgt_device
"" ne $tgt_device
Truth table33%1/3
A and B
A= defined $tgt_deviceB= "" ne $tgt_device
| |||||||||||||||||||||||||||||
| 42 | and '' ne $tgt_device | ||||||||||||||||||||||||||||
| 43 | and $tgt_dir = File::Spec->catdir( $tgt_device, $tgt_dir ); | ||||||||||||||||||||||||||||
| 44 | 1 | my $relative = File::Spec->abs2rel( $source, $tgt_dir ); | |||||||||||||||||||||||||||
| 45 | 1 | return symlink $relative, $target; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 2 | 1; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | __END__ | ||||||||||||||||||||||||||||