From: Jarkko Hietaniemi Date: Wed, 12 Mar 2003 13:49:15 +0000 (+0000) Subject: File::Temp tests were failing in Cygwin if $ENV{TMPDIR} X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f534ab209a30d0742128f9b80e76ccadd18af778;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/lib/File/Spec/Cygwin.pm b/lib/File/Spec/Cygwin.pm index 8773288..ac4e839 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__