blib/lib/File/Spec/Cygwin.pm

filter: Statementstmt 50.0% 25 / 50 Branchbran 39.2% 11 / 28 Conditioncond 40.0% 6 / 15 MC/DCmcdc 22.2% 2 / 9 Subroutinesub 83.3% 5 / 6 Podpod 100% 5 / 5 totaltotal 47.7% 54 / 113 CC 20 SCAR 41.7
CC
20
Cov
45%
case_tolerant
130.7
tmpdir
6.0
catdir
5.0
CRAP 64.8
« blib/lib/Cwd.pm ↑ Summary blib/lib/File/Spec/VMS.pm »
1 package File::Spec::Cygwin;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 require File::Spec::Unix;
5  
6 2 our $VERSION = '3.75';
7 2 $VERSION =~ tr/_//d;
8  
9 2 our @ISA = qw(File::Spec::Unix);
10  
11 =head1 NAME
12  
13 File::Spec::Cygwin - methods for Cygwin file specs
14  
15 =head1 SYNOPSIS
16  
17 require File::Spec::Cygwin; # Done internally by File::Spec if needed
18  
19 =head1 DESCRIPTION
20  
21 See L<File::Spec> and L<File::Spec::Unix>. This package overrides the
22 implementation of these methods, not the semantics.
23  
24 This module is still in beta. Cygwin-knowledgeable folks are invited
25 to offer patches and suggestions.
26  
27 =cut
28  
29 =pod
30  
31 =over 4
32  
33 =item canonpath
34  
35 Any C<\> (backslashes) are converted to C</> (forward slashes),
36 and then File::Spec::Unix canonpath() is called on the result.
37  
38 =cut
39  
40 184 ▶sub canonpath {
Subroutine canonpath: called CC=3 SCAR=11.0
Pod documented
41 184 my($self,$path) = @_;
42 184 ▶ return unless defined $path;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path 2 182 184
43  
44 182 $path =~ s|\\|/|g;
45  
46 # Handle network path names beginning with double slash
47 182 my $node = '';
48 182 ▶ if ( $path =~ s@^(//[^/]+)(?:/|\z)@/@s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ s[^(//[^/]+)(?:/|\z)][/]s) 1 181 182
49 1 $node = $1;
50 }
51 182 return $node . $self->SUPER::canonpath($path);
52 }
53  
54 53 ▶sub catdir {
Subroutine catdir: called CC=5 SCAR=16.1
Pod documented
55 53 my $self = shift;
56 53 ▶ return unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1 52 53
57  
58 # Don't create something that looks like a //network/path
59 52 ▶ if ($_[0] and ($_[0] eq '/' or $_[0] eq '\\')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] and $_[0] eq "/" || $_[0] eq "\\") 11 41 52
Condition83%5/6
$_[0] and $_[0] eq "/" || $_[0] eq "\\"
!ll&&!rl&&r
33811
$_[0] eq "/" or $_[0] eq "\\"
l!l&&r!l&&!r
11038
MC/DC66%2/3
$_[0] and $_[0] eq "/" || $_[0] eq "\\"
$_[0] $_[0] eq "/" $_[0] eq "\\"
Truth table75%3/4
A and B or C
A= $_[0]B= $_[0] eq "/"C= $_[0] eq "\\"
ABCresult
0XX0
1000
11X1
1011
60 11 shift;
61 11 return $self->SUPER::catdir('', @_);
62 }
63  
64 41 $self->SUPER::catdir(@_);
65 }
66  
67 =pod
68  
69 =item file_name_is_absolute
70  
71 True is returned if the file name begins with C<drive_letter:>,
72 and if not, File::Spec::Unix file_name_is_absolute() is called.
73  
74 =cut
75  
76  
77 93 ▶sub file_name_is_absolute {
Subroutine file_name_is_absolute: called CC=2 SCAR=6.9
Pod documented
78 93 my ($self,$file) = @_;
79 93 ▶ return 1 if $file =~ m{^([a-z]:)?[\\/]}is; # C:/test
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ m[^([a-z]:)?[\\/]]is 84 9 93
80 9 return $self->SUPER::file_name_is_absolute($file);
81 }
82  
83 =item tmpdir (override)
84  
85 Returns a string representation of the first existing directory
86 from the following list:
87  
88 $ENV{TMPDIR}
89 /tmp
90 $ENV{'TMP'}
91 $ENV{'TEMP'}
92 C:/temp
93  
94 If running under taint mode, and if the environment
95 variables are tainted, they are not used.
96  
97 =cut
98  
99 0 ▶sub tmpdir {
Subroutine tmpdir: not called CC=2 SCAR=17.9
Pod documented
100 0 my $cached = $_[0]->_cached_tmpdir(qw 'TMPDIR TMP TEMP');
101 0 ▶ return $cached if defined $cached;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cached 0 0 0
102 $_[0]->_cache_tmpdir(
103 $_[0]->_tmpdir(
104 0 $ENV{TMPDIR}, "/tmp", $ENV{'TMP'}, $ENV{'TEMP'}, 'C:/temp'
105 ),
106 qw 'TMPDIR TMP TEMP'
107 );
108 }
109  
110 =item case_tolerant
111  
112 Override Unix. Cygwin case-tolerance depends on managed mount settings and
113 as with MsWin32 on GetVolumeInformation() $ouFsFlags == FS_CASE_SENSITIVE,
114 indicating the case significance when comparing file specifications.
115 Default: 1
116  
117 =cut
118  
119 1 ▶sub case_tolerant {
Subroutine case_tolerant: called CC=12 SCAR=48.7
Pod documented
120 1 ▶ return 1 unless $^O eq 'cygwin'
Branch: 1 branch
BranchTrueFalseTotal
unless $^O eq "cygwin" and defined &Cygwin::mount_flags 1 0 1
Condition33%1/3
$^O eq "cygwin" and defined &Cygwin::mount_flags
!ll&&!rl&&r
100
MC/DC0%0/2
$^O eq "cygwin" and defined &Cygwin::mount_flags
$^O eq "cygwin" defined &Cygwin::mount_flags
Truth table33%1/3
A and B
A= $^O eq "cygwin"B= defined &Cygwin::mount_flags
ABresult
0X0
100
111
121 and defined &Cygwin::mount_flags;
122  
123 0 my $drive = shift;
124 0 ▶ if (! $drive) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($drive) 0 0 0
125 0 my @flags = split(/,/, Cygwin::mount_flags('/cygwin'));
126 0 my $prefix = pop(@flags);
127 0 ▶ if (! $prefix || $prefix eq 'cygdrive') {
Branch: 2 branches
BranchTrueFalseTotal
if (not $prefix or $prefix eq 'cygdrive') { } 0 0 0
elsif ($prefix eq '/') { } 0 0 0
Condition0%0/3
not $prefix or $prefix eq "cygdrive"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $prefix or $prefix eq "cygdrive"
not $prefix $prefix eq "cygdrive"
Truth table0%0/3
not(A) or B
A= not $prefixB= $prefix eq "cygdrive"
ABresult
1X1
011
000
128 0 $drive = '/cygdrive/c';
129 } elsif ($prefix eq '/') {
130 0 $drive = '/c';
131 } else {
132 0 $drive = "$prefix/c";
133 }
134 }
135 0 my $mntopts = Cygwin::mount_flags($drive);
136 0 ▶ if ($mntopts and ($mntopts =~ /,managed/)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mntopts and $mntopts =~ /,managed/) 0 0 0
Condition0%0/3
$mntopts and $mntopts =~ /,managed/
!ll&&!rl&&r
000
MC/DC0%0/2
$mntopts and $mntopts =~ /,managed/
$mntopts $mntopts =~ /,managed/
Truth table0%0/3
A and B
A= $mntoptsB= $mntopts =~ /,managed/
ABresult
0X0
100
111
137 0 return 0;
138 }
139 0 ▶ eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { local(@INC) = @INC; pop @INC if $INC[-1] eq "."; require Win32API::File } } or return 1 0 0 0
140 0 local @INC = @INC;
141 0 ▶ pop @INC if $INC[-1] eq '.';
Branch: 1 branch
BranchTrueFalseTotal
if $INC[-1] eq "." 0 0 0
142 0 require Win32API::File;
143 } or return 1;
144 0 my $osFsType = "\0"x256;
145 0 my $osVolName = "\0"x256;
146 0 my $ouFsFlags = 0;
147 0 Win32API::File::GetVolumeInformation($drive, $osVolName, 256, [], [], $ouFsFlags, $osFsType, 256 );
148 0 ▶ if ($ouFsFlags & Win32API::File::FS_CASE_SENSITIVE()) { return 0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($ouFsFlags & Win32API::File::FS_CASE_SENSITIVE()) { } 0 0 0
149 0 else { return 1; }
150 }
151  
152 =back
153  
154 =head1 COPYRIGHT
155  
156 Copyright (c) 2004,2007 by the Perl 5 Porters. All rights reserved.
157  
158 This program is free software; you can redistribute it and/or modify
159 it under the same terms as Perl itself.
160  
161 =cut
162  
163 2 1;
« blib/lib/Cwd.pm ↑ Summary blib/lib/File/Spec/VMS.pm »