develooper Front page | perl.perl5.porters | Postings from January 2008

[PATCH] v5.8.8: File::Temp.pm (_gettemp): ignore dir -w test on Cygwin

Thread Next
From:
Jari Aalto
Date:
January 5, 2008 03:22
Subject:
[PATCH] v5.8.8: File::Temp.pm (_gettemp): ignore dir -w test on Cygwin
Message ID:
bq8034ba.fsf@blue.sea.net

[Please keep CC]

Installing CPAN modules fails, because of File::Temp runs a -w check on
directory. Under Cygwin (FAT32), following happens:

    $ echo $CYGWIN
    server

    $ umask 002; mkdir test; ls -la test
    dr-xr-xr-x  2 root None 0 Jan  3 21:17 .
    dr-xr-xr-x 15 root None 0 Jul 25 16:03 ..

    $ chmod 777 test; ls -la test
    dr-xr-xr-x  2 root None 0 Jan  3 21:17 .
    dr-xr-xr-x 15 root None 0 Jul 25 16:03 ..

    $ touch test/new.file
    $ ls -la test
    dr-xr-xr-x  2 root None 0 Jan  3 21:17 .
    dr-xr-xr-x 15 root None 0 Jul 25 16:03 ..
    -rw-r--r--  1 root None 0 Jan  3 21:18 new.file

    $ rm test/new.file ; echo $?
    0

See patch below,
Jari


From 8769ce48fd8ea9c0702b85b89b0d8545f9a80857 Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto AT cante.net>
Date: Thu, 3 Jan 2008 21:15:09 +0200
Subject: [PATCH] Temp.pm:(_gettemp): ignore dir -w test on Cygwin

Signed-off-by: Jari Aalto <jari.aalto AT cante.net>
---
 Temp.pm |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/Temp.pm b/Temp.pm
index b933963..1cc3ede 100644
--- a/Temp.pm
+++ b/Temp.pm
@@ -441,7 +441,13 @@ sub _gettemp {
     ${$options{ErrStr}} = "Parent directory ($parent) is not a directory";
     return ();
   }
-  unless (-w $parent) {
+
+  if ( $^O =~ /cygwin/i ) {
+      #   No-op special case. Under Windows Cygwin (FAT32) the directory
+      #   permissions cannot be trusted. Directories are always
+      #   writable.
+  }
+  elsif (not -w $parent) {
     ${$options{ErrStr}} = "Parent directory ($parent) is not writable\n";
       return ();
   }
-- 
1.5.4-rc0.GIT



-- 
Welcome to FOSS revolution: we fix and modify until it shines

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About