| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition83%5/6
$_[0] and $_[0] eq "/" || $_[0] eq "\\"
$_[0] eq "/" or $_[0] eq "\\"
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 "\\"
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$^O eq "cygwin" and defined &Cygwin::mount_flags
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
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | and defined &Cygwin::mount_flags; | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $drive = shift; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if (! $drive) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
not $prefix or $prefix eq "cygdrive"
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"
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$mntopts and $mntopts =~ /,managed/
MC/DC0%0/2
$mntopts and $mntopts =~ /,managed/
$mntopts
$mntopts =~ /,managed/
Truth table0%0/3
A and B
A= $mntoptsB= $mntopts =~ /,managed/
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | local @INC = @INC; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | pop @INC if $INC[-1] eq '.'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||||||||||||||||