Change 31709 by [EMAIL PROTECTED] on 2007/08/14 06:57:08

        Subject: [PATCH] CYG07-File-Spec-case_tolerant
        From: Reini Urban <[EMAIL PROTECTED]>
        Date: Tue, 14 Aug 2007 08:45:34 +0200
        Message-Id: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/lib/File/Spec/Cygwin.pm#16 edit
... //depot/perl/lib/File/Spec/Win32.pm#44 edit

Differences ...

==== //depot/perl/lib/File/Spec/Cygwin.pm#16 (text) ====
Index: perl/lib/File/Spec/Cygwin.pm
--- perl/lib/File/Spec/Cygwin.pm#15~31440~      2007-06-21 01:34:35.000000000 
-0700
+++ perl/lib/File/Spec/Cygwin.pm        2007-08-13 23:57:08.000000000 -0700
@@ -4,7 +4,7 @@
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '1.1_01';
+$VERSION = '1.1_02';
 
 @ISA = qw(File::Spec::Unix);
 
@@ -84,6 +84,8 @@
 
     $ENV{TMPDIR}
     /tmp
+    $ENV{'TMP'}
+    $ENV{'TEMP'}
     C:/temp
 
 Since Perl 5.8.0, if running under taint mode, and if the environment
@@ -94,23 +96,38 @@
 my $tmpdir;
 sub tmpdir {
     return $tmpdir if defined $tmpdir;
-    $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp", 'C:/temp' );
+    $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp", $ENV{'TMP'}, $ENV{'TEMP'}, 
'C:/temp' );
 }
 
 =item case_tolerant
 
-Override Unix. Cygwin is always case-tolerant, indicating that it is not
-significant when comparing file specifications.
+Override Unix. Cygwin case-tolerance depends on managed mount settings and
+as with MsWin32 on GetVolumeInformation() $ouFsFlags == FS_CASE_SENSITIVE,
+indicating the case significance when comparing file specifications.
+Default: 1
 
 =cut
 
-sub case_tolerant () { 1 }
+sub case_tolerant () {
+  my $drive = shift || "C:";
+  my $mntopts = Cygwin::mount_flags($drive);
+  if ($mntopts and ($mntopts =~ /,managed/)) {
+    return 0;
+  }
+  eval { require Win32API::File; } or return 1;
+  my $osFsType = "\0"x256;
+  my $osVolName = "\0"x256;
+  my $ouFsFlags = 0;
+  Win32API::File::GetVolumeInformation($drive, $osVolName, 256, [], [], 
$ouFsFlags, $osFsType, 256 );
+  if ($ouFsFlags & Win32API::File::FS_CASE_SENSITIVE()) { return 0; }
+  else { return 1; }
+}
 
 =back
 
 =head1 COPYRIGHT
 
-Copyright (c) 2004 by the Perl 5 Porters.  All rights reserved.
+Copyright (c) 2004,2007 by the Perl 5 Porters.  All rights reserved.
 
 This program is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.

==== //depot/perl/lib/File/Spec/Win32.pm#44 (text) ====
Index: perl/lib/File/Spec/Win32.pm
--- perl/lib/File/Spec/Win32.pm#43~29004~       2006-10-12 08:07:17.000000000 
-0700
+++ perl/lib/File/Spec/Win32.pm 2007-08-13 23:57:08.000000000 -0700
@@ -77,13 +77,35 @@
                              '/'  );
 }
 
-sub case_tolerant {
-    return 1;
+=item case_tolerant
+
+MSWin32 case-tolerance depends on GetVolumeInformation() $ouFsFlags == 
FS_CASE_SENSITIVE,
+indicating the case significance when comparing file specifications.
+Since XP FS_CASE_SENSITIVE is effectively disabled for the NT subsubsystem.
+See http://cygwin.com/ml/cygwin/2007-07/msg00891.html
+Default: 1
+
+=cut
+
+sub case_tolerant () {
+  eval { require Win32API::File; } or return 1;
+  my $drive = shift or "C:";
+  my $osFsType = "\0"x256;
+  my $osVolName = "\0"x256;
+  my $ouFsFlags = 0;
+  Win32API::File::GetVolumeInformation($drive, $osVolName, 256, [], [], 
$ouFsFlags, $osFsType, 256 );
+  if ($ouFsFlags & Win32API::File::FS_CASE_SENSITIVE()) { return 0; }
+  else { return 1; }
 }
 
+=item file_name_is_absolute
+
+As of right now, this returns 2 if the path is absolute with a
+volume, 1 if it's absolute with no volume, 0 otherwise.
+
+=cut
+
 sub file_name_is_absolute {
-    # As of right now, this returns 2 if the path is absolute with a
-    # volume, 1 if it's absolute with no volume, 0 otherwise.
 
     my ($self,$file) = @_;
 
@@ -341,7 +363,7 @@
 
 =head1 COPYRIGHT
 
-Copyright (c) 2004 by the Perl 5 Porters.  All rights reserved.
+Copyright (c) 2004,2007 by the Perl 5 Porters.  All rights reserved.
 
 This program is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.
End of Patch.

Reply via email to