line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Symlink::Relative; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
21562
|
use 5.008001; |
|
2
|
|
|
|
|
15
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
6
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
106
|
|
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
|
|
|
2
|
|
977
|
no if $] ge '5.020', feature => qw{ signatures }; |
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
15
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
344
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
212
|
|
13
|
2
|
|
|
2
|
|
16
|
use Exporter qw{ import }; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
78
|
|
14
|
2
|
|
|
2
|
|
13
|
use File::Spec; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
301
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.004_01'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ |
19
|
|
|
|
|
|
|
symlink_r |
20
|
|
|
|
|
|
|
SYMLINK_SUPPORTED |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
our @EXPORT = qw{ symlink_r }; ## no critic (ProhibitAutomaticExportation) |
23
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
24
|
|
|
|
|
|
|
all => \@EXPORT_OK, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
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
|
|
50
|
2
|
|
16
|
use constant SYMLINK_SUPPORTED => eval { symlink '', ''; 1 } || 0; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
3
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub symlink_r ($$) { ## no critic (ProhibitSubroutinePrototypes) |
39
|
1
|
|
|
1
|
1
|
963
|
my ( $source, $target ) = @_; |
40
|
1
|
|
|
|
|
36
|
my ( $tgt_device, $tgt_dir ) = File::Spec->splitpath( $target ); |
41
|
1
|
50
|
33
|
|
|
11
|
defined $tgt_device |
42
|
|
|
|
|
|
|
and '' ne $tgt_device |
43
|
|
|
|
|
|
|
and $tgt_dir = File::Spec->catdir( $tgt_device, $tgt_dir ); |
44
|
1
|
|
|
|
|
90
|
my $relative = File::Spec->abs2rel( $source, $tgt_dir ); |
45
|
1
|
|
|
|
|
67
|
return symlink $relative, $target; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |