1 package File::Spec::Cygwin;
4 require File::Spec::Unix;
9 our @ISA = qw(File::Spec::Unix);
13 File::Spec::Cygwin - methods for Cygwin file specs
17 require File::Spec::Cygwin; # Done internally by File::Spec if needed
21 See L<File::Spec> and L<File::Spec::Unix>. This package overrides the
22 implementation of these methods, not the semantics.
24 This module is still in beta. Cygwin-knowledgeable folks are invited
25 to offer patches and suggestions.
35 Any C<\> (backslashes) are converted to C</> (forward slashes),
36 and then File::Spec::Unix canonpath() is called on the result.
42 return unless defined $path;
46 # Handle network path names beginning with double slash
48 if ( $path =~ s@^(//[^/]+)(?:/|\z)@/@s ) {
51 return $node . $self->SUPER::canonpath($path);
58 # Don't create something that looks like a //network/path
59 if ($_[0] and ($_[0] eq '/' or $_[0] eq '\\')) {
61 return $self->SUPER::catdir('', @_);
64 $self->SUPER::catdir(@_);
69 =item file_name_is_absolute
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.
77 sub file_name_is_absolute {
78 my ($self,$file) = @_;
79 return 1 if $file =~ m{^([a-z]:)?[\\/]}is; # C:/test
80 return $self->SUPER::file_name_is_absolute($file);
83 =item tmpdir (override)
85 Returns a string representation of the first existing directory
86 from the following list:
94 If running under taint mode, and if the environment
95 variables are tainted, they are not used.
100 my $cached = $_[0]->_cached_tmpdir(qw 'TMPDIR TMP TEMP');
101 return $cached if defined $cached;
102 $_[0]->_cache_tmpdir(
104 $ENV{TMPDIR}, "/tmp", $ENV{'TMP'}, $ENV{'TEMP'}, 'C:/temp'
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.
120 return 1 unless $^O eq 'cygwin'
121 and defined &Cygwin::mount_flags;
125 my @flags = split(/,/, Cygwin::mount_flags('/cygwin'));
126 my $prefix = pop(@flags);
127 if (! $prefix || $prefix eq 'cygdrive') {
128 $drive = '/cygdrive/c';
129 } elsif ($prefix eq '/') {
132 $drive = "$prefix/c";
135 my $mntopts = Cygwin::mount_flags($drive);
136 if ($mntopts and ($mntopts =~ /,managed/)) {
141 pop @INC if $INC[-1] eq '.';
142 require Win32API::File;
144 my $osFsType = "\0"x256;
145 my $osVolName = "\0"x256;
147 Win32API::File::GetVolumeInformation($drive, $osVolName, 256, [], [], $ouFsFlags, $osFsType, 256 );
148 if ($ouFsFlags & Win32API::File::FS_CASE_SENSITIVE()) { return 0; }
156 Copyright (c) 2004,2007 by the Perl 5 Porters. All rights reserved.
158 This program is free software; you can redistribute it and/or modify
159 it under the same terms as Perl itself.