line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Copy::Link; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
57337
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
155
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
16
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
184
|
|
7
|
2
|
|
|
2
|
|
1967
|
use File::Copy (); |
|
2
|
|
|
|
|
15777
|
|
|
2
|
|
|
|
|
77
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
2
|
|
|
2
|
|
16
|
use base qw(Exporter); |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
17735
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(copylink safecopylink); |
13
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub copylink { |
16
|
1
|
50
|
|
1
|
1
|
1797
|
local $_ = @_ ? shift : $_; # default to $_ |
17
|
1
|
50
|
|
|
|
22
|
croak "$_ not a link\n" unless -l; |
18
|
1
|
50
|
|
|
|
123
|
open my $fh, '<', $_ or croak "Can't open link $_: $!\n"; |
19
|
1
|
50
|
|
|
|
79
|
unlink or croak "Can't unlink link $_: $!\n"; |
20
|
1
|
|
|
|
|
8
|
my $ok = File::Copy::copy $fh, $_; |
21
|
1
|
50
|
|
|
|
313
|
croak "copy($fh $_) failed: $!\n" unless $ok; |
22
|
1
|
|
|
|
|
18
|
return $ok; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub safecopylink { |
26
|
1
|
50
|
|
1
|
1
|
23729
|
local $_ = @_ ? shift : $_; # default to $_ |
27
|
1
|
50
|
|
|
|
27
|
croak "$_ not a link\n" unless -l; |
28
|
1
|
|
|
|
|
1093
|
require File::Spec::Link; |
29
|
1
|
|
|
|
|
8
|
my $orig = File::Spec::Link->linked($_); |
30
|
1
|
50
|
|
|
|
5
|
croak "$_ link problem\n" unless defined $orig; |
31
|
1
|
50
|
|
|
|
224
|
unlink or croak "Can't unlink link $_: $!\n"; |
32
|
1
|
|
|
|
|
7
|
my $ok = File::Copy::copy $orig, $_; |
33
|
1
|
50
|
|
|
|
649
|
croak "copy($orig $_) failed: $!\n" unless $ok; |
34
|
1
|
|
|
|
|
9
|
return $ok; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
__END__ |