blib/lib/ExtUtils/Helpers/VMS.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 64 SCAR 42.8
CC
8
Cov
0%
detildefy
72.0
make_executable
2.0
BEGIN
2.0
CRAP 72.0
1 package ExtUtils::Helpers::VMS;
2 $ExtUtils::Helpers::VMS::VERSION = '0.026';
3 use strict;
4 use warnings FATAL => 'all';
5  
6 use Exporter 5.57 'import';
7 our @EXPORT = qw/make_executable detildefy/;
8  
9 use File::Copy qw/copy/;
10  
11 sub make_executable {
12 my $filename = shift;
13 my $batchname = "$filename.com";
14 copy($filename, $batchname);
15 ExtUtils::Helpers::Unix::make_executable($batchname);
16 return;
17 }
18  
19 sub detildefy {
20 my $arg = shift;
21  
22 # Apparently double ~ are not translated.
23 return $arg if ($arg =~ /^~~/);
24  
25 # Apparently ~ followed by whitespace are not translated.
26 return $arg if ($arg =~ /^~ /);
27  
28 if ($arg =~ /^~/) {
29 my $spec = $arg;
30  
31 # Remove the tilde
32 $spec =~ s/^~//;
33  
34 # Remove any slash following the tilde if present.
35 $spec =~ s#^/##;
36  
37 # break up the paths for the merge
38 my $home = VMS::Filespec::unixify($ENV{HOME});
39  
40 # In the default VMS mode, the trailing slash is present.
41 # In Unix report mode it is not. The parsing logic assumes that
42 # it is present.
43 $home .= '/' unless $home =~ m#/$#;
44  
45 # Trivial case of just ~ by it self
46 if ($spec eq '') {
47 $home =~ s#/$##;
48 return $home;
49 }
50  
51 my ($hvol, $hdir, $hfile) = File::Spec::Unix->splitpath($home);
52 if ($hdir eq '') {
53 # Someone has tampered with $ENV{HOME}
54 # So hfile is probably the directory since this should be
55 # a path.
56 $hdir = $hfile;
57 }
58  
59 my ($vol, $dir, $file) = File::Spec::Unix->splitpath($spec);
60  
61 my @hdirs = File::Spec::Unix->splitdir($hdir);
62 my @dirs = File::Spec::Unix->splitdir($dir);
63  
64 unless ($arg =~ m#^~/#) {
65 # There is a home directory after the tilde, but it will already
66 # be present in in @hdirs so we need to remove it by from @dirs.
67  
68 shift @dirs;
69 }
70 my $newdirs = File::Spec::Unix->catdir(@hdirs, @dirs);
71  
72 $arg = File::Spec::Unix->catpath($hvol, $newdirs, $file);
73 }
74 return $arg;
75 }
76  
77 # ABSTRACT: VMS specific helper bits
78  
79 __END__