PFT/Util.pm untested

filter: Statementstmt 0.0% 0 / 51 Branchbran n/a Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 98 CC 1 SCAR 6.9
CC
1
Cov
0%
ln
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 # Copyright 2014-2019 - Giovanni Simoni
2 #
3 # This file is part of PFT.
4 #
5 # PFT is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your
8 # option) any later version.
9 #
10 # PFT is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with PFT. If not, see <http://www.gnu.org/licenses/>.
17 #
18 package App::PFT::Util v1.4.1;
19  
20 use strict;
21 use warnings;
22  
23 use Exporter qw/import/;
24 our @EXPORT_OK = qw/
25 ln
26 /;
27  
28 use Carp;
29  
30 use Encode;
31 use Encode::Locale;
32  
33 use File::Copy::Recursive qw/dircopy/;
34 use File::Path qw/remove_tree make_path/;
35 use File::Spec::Functions qw/updir catfile catdir rootdir/;
36 use File::Basename qw/dirname/;
37 use Cwd qw/abs_path cwd/;
38  
39 sub ln {
40 my($from, $to, $verbose) = @_;
41 my $ok;
42  
43 -e $to && remove_tree $to, {verbose => $verbose};
44 make_path dirname $to;
45 $verbose and say STDERR "Linking $from to $to";
46 $ok = link($from, $to);
47 $ok and return 1;
48 $verbose and say STDERR "Could not hardlink: $!. Symlinking";
49 $ok = eval { symlink($from, $to) };
50 $ok and return 1;
51 $verbose and say STDERR "Could not symlink: $@$!. Copying";
52 remove_tree $to, {verbose => $verbose};
53 $ok = dircopy $from, $to;
54 $ok and return 1;
55 $verbose and say STDERR "Everything failed";
56 return '';
57 }
58  
59 1;