summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-03-12 13:49:15 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-03-12 13:49:15 +0000
commitf534ab209a30d0742128f9b80e76ccadd18af778 (patch)
tree0c89a70cbaa54844d3b394892c9f347dcc2783e0
parenta73e8557ffb104ab62198e9838714843724d84e5 (diff)
downloadperl-f534ab209a30d0742128f9b80e76ccadd18af778.tar.gz
File::Temp tests were failing in Cygwin if $ENV{TMPDIR}
was unset (the tests attempted to create files at the /) p4raw-id: //depot/perl@18955
-rw-r--r--lib/File/Spec/Cygwin.pm20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/File/Spec/Cygwin.pm b/lib/File/Spec/Cygwin.pm
index 877328898d..ac4e8393b5 100644
--- a/lib/File/Spec/Cygwin.pm
+++ b/lib/File/Spec/Cygwin.pm
@@ -20,6 +20,26 @@ sub file_name_is_absolute {
return $self->SUPER::file_name_is_absolute($file);
}
+my $tmpdir;
+sub tmpdir {
+ return $tmpdir if defined $tmpdir;
+ my @dirlist = ($ENV{TMPDIR}, "/tmp", 'C:/temp');
+ {
+ no strict 'refs';
+ if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0
+ require Scalar::Util;
+ shift @dirlist if Scalar::Util::tainted($ENV{TMPDIR});
+ }
+ }
+ foreach (@dirlist) {
+ next unless defined && -d && -w _;
+ $tmpdir = $_;
+ last;
+ }
+ $tmpdir = '' unless defined $tmpdir;
+ return $tmpdir;
+}
+
1;
__END__