summaryrefslogtreecommitdiff
path: root/lib/File/Spec/OS2.pm
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-03-14 13:42:32 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-03-14 13:42:32 +0000
commit07824bd1cfb16e641e5040a9a4e23799f5535a53 (patch)
tree94d58132d4adec2beef7fb3afdd83a4defd65e7d /lib/File/Spec/OS2.pm
parent7f1236c00d2708a214ae3f72897a3a14ec6d9792 (diff)
downloadperl-07824bd1cfb16e641e5040a9a4e23799f5535a53.tar.gz
Cleanup the File::Spec tmpdir() implementations:
now all the platforms specific modules call _tmpdir() (inherited from Unix.pm) with the list of platform specific list of temporary directories, and _tmpdir() then does the appropriate suitability checking. p4raw-id: //depot/perl@18980
Diffstat (limited to 'lib/File/Spec/OS2.pm')
-rw-r--r--lib/File/Spec/OS2.pm40
1 files changed, 22 insertions, 18 deletions
diff --git a/lib/File/Spec/OS2.pm b/lib/File/Spec/OS2.pm
index 810ef8c6b8..9bd9381a67 100644
--- a/lib/File/Spec/OS2.pm
+++ b/lib/File/Spec/OS2.pm
@@ -4,7 +4,7 @@ use strict;
use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '1.1';
+$VERSION = '1.2';
@ISA = qw(File::Spec::Unix);
@@ -29,27 +29,31 @@ sub path {
return @path;
}
+=pod
+
+=item tmpdir
+
+Returns a string representation of the first existing directory
+from the following list:
+
+ $ENV{TMPDIR}
+ $ENV{TEMP}
+ $ENV{TMP}
+ /tmp
+ /
+
+Since Perl 5.8.0, if running under taint mode, and if the environment
+variables are tainted, they are not used.
+
+=cut
+
my $tmpdir;
sub tmpdir {
return $tmpdir if defined $tmpdir;
my $self = shift;
- my @dirlist = ( @ENV{qw(TMPDIR TEMP TMP)}, qw(/tmp /) );
- {
- no strict 'refs';
- if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0
- require Scalar::Util;
- @dirlist = grep { ! Scalar::Util::tainted $_ } @dirlist;
- }
- }
- foreach (@dirlist) {
- next unless defined && -d;
- $tmpdir = $_;
- last;
- }
- $tmpdir = File::Spec->curdir unless defined $tmpdir;
- $tmpdir =~ s:\\:/:g;
- $tmpdir = $self->canonpath($tmpdir);
- return $tmpdir;
+ $tmpdir = $self->_tmpdir( @ENV{qw(TMPDIR TEMP TMP)},
+ '/tmp',
+ '/' );
}
=item canonpath