package File::Spec;
use strict;
-our(@ISA, $VERSION);
+use vars qw(@ISA $VERSION);
-$VERSION = 0.83 ;
+$VERSION = 0.84 ;
my %module = (MacOS => 'Mac',
MSWin32 => 'Win32',
=item tmpdir
Returns a string representation of the first writable directory from a
-list of possible temporary directories. Returns "" if no writable
-temporary directories are found. The list of directories checked
-depends on the platform; e.g. File::Spec::Unix checks $ENV{TMPDIR} and
-/tmp.
+list of possible temporary directories. Returns the current directory
+if no writable temporary directories are found. The list of directories
+checked depends on the platform; e.g. File::Spec::Unix checks $ENV{TMPDIR}
+(unless taint is on) and /tmp.
$tmpdir = File::Spec->tmpdir();
+
package File::Spec::Cygwin;
use strict;
@ISA = qw(File::Spec::Unix);
+=head1 NAME
+
+File::Spec::Cygwin - methods for Cygwin file specs
+
+=head1 SYNOPSIS
+
+ require File::Spec::Cygwin; # Done internally by File::Spec if needed
+
+=head1 DESCRIPTION
+
+See File::Spec::Unix for a documentation of the methods provided
+there. This package overrides the implementation of these methods, not
+the semantics.
+
+This module is still in beta. Cygwin-knowledgeable folks are invited
+to offer patches and suggestions.
+
+=cut
+
+=pod
+
+=item canonpath
+
+Any C<\> (backslashes) are converted to C</> (forward slashes),
+and then File::Spec::Unix canonpath() is called on the result.
+
+=cut
+
sub canonpath {
my($self,$path) = @_;
$path =~ s|\\|/|g;
return $self->SUPER::canonpath($path);
}
+=pod
+
+=item file_name_is_absolute
+
+True is returned if the file name begins with C<drive_letter:>,
+and if not, File::Spec::Unix file_name_is_absolute() is called.
+
+=cut
+
+
sub file_name_is_absolute {
my ($self,$file) = @_;
return 1 if $file =~ m{^([a-z]:)?[\\/]}is; # C:/test
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 = File::Spec->curdir unless defined $tmpdir;
- return $tmpdir;
-}
+=item tmpdir (override)
-1;
-__END__
-
-=head1 NAME
+Returns a string representation of the first existing directory
+from the following list:
-File::Spec::Cygwin - methods for Cygwin file specs
+ $ENV{TMPDIR}
+ /tmp
+ C:/temp
-=head1 SYNOPSIS
+Since Perl 5.8.0, if running under taint mode, and if the environment
+variables are tainted, they are not used.
- require File::Spec::Cygwin; # Done internally by File::Spec if needed
+=cut
-=head1 DESCRIPTION
-
-See File::Spec::Unix for a documentation of the methods provided
-there. This package overrides the implementation of these methods, not
-the semantics.
+my $tmpdir;
+sub tmpdir {
+ return $tmpdir if defined $tmpdir;
+ my $self = shift;
+ $tmpdir = $self->_tmpdir( $ENV{TMPDIR}, "/tmp", 'C:/temp' );
+}
-This module is still in beta. Cygwin-knowledgeable folks are invited
-to offer patches and suggestions.
+1;
package File::Spec::Epoc;
-our $VERSION = '1.00';
-
use strict;
use Cwd;
-use vars qw(@ISA);
+use vars qw($VERSION @ISA);
+
+$VERSION = '1.1';
+
require File::Spec::Unix;
@ISA = qw(File::Spec::Unix);
use File::Spec;
use strict;
-our (@ISA,@EXPORT,@EXPORT_OK,%EXPORT_TAGS,$VERSION);
+use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
-$VERSION = '1.2';
+$VERSION = '1.3';
require Exporter;
use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '1.3';
+$VERSION = '1.4';
@ISA = qw(File::Spec::Unix);
=item tmpdir
-Returns the contents of $ENV{TMPDIR}, if that directory exits or the current working
-directory otherwise. Under MacPerl, $ENV{TMPDIR} will contain a path like
-"MacintoshHD:Temporary Items:", which is a hidden directory on your startup volume.
+Returns the contents of $ENV{TMPDIR}, if that directory exits or the
+current working directory otherwise. Under MacPerl, $ENV{TMPDIR} will
+contain a path like "MacintoshHD:Temporary Items:", which is a hidden
+directory on your startup volume.
=cut
my $tmpdir;
sub tmpdir {
return $tmpdir if defined $tmpdir;
- $tmpdir = $ENV{TMPDIR} if -d $ENV{TMPDIR};
- $tmpdir = File::Spec->curdir unless defined $tmpdir;
- return $tmpdir;
+ my $self = shift;
+ $tmpdir = $self->_tmpdir( $ENV{TMPDIR} );
}
=item updir
use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '1.1';
+$VERSION = '1.2';
@ISA = qw(File::Spec::Unix);
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
package File::Spec::Unix;
use strict;
-our($VERSION);
+use vars qw($VERSION);
$VERSION = '1.4';
=item tmpdir
-Returns a string representation of the first writable directory
-from the following list or "" if none are writable:
+Returns a string representation of the first writable directory from
+the following list or the current directory if none from the list are
+writable:
$ENV{TMPDIR}
/tmp
=cut
my $tmpdir;
-sub tmpdir {
+sub _tmpdir {
return $tmpdir if defined $tmpdir;
- my @dirlist = ($ENV{TMPDIR}, "/tmp");
+ my $self = shift;
+ my @dirlist = @_;
{
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});
+ @dirlist = grep { ! Scalar::Util::tainted($_) } @dirlist;
}
}
foreach (@dirlist) {
$tmpdir = $_;
last;
}
- $tmpdir = File::Spec->curdir unless defined $tmpdir;
+ $tmpdir = $self->curdir unless defined $tmpdir;
+ $tmpdir = defined $tmpdir && $self->canonpath($tmpdir);
return $tmpdir;
}
+sub tmpdir {
+ return $tmpdir if defined $tmpdir;
+ $tmpdir = _tmpdir( $ENV{TMPDIR}, "/tmp" );
+}
+
=item updir
Returns a string representation of the parent directory. ".." on UNIX.
use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '1.2';
+$VERSION = '1.4';
@ISA = qw(File::Spec::Unix);
my $tmpdir;
sub tmpdir {
return $tmpdir if defined $tmpdir;
- my @dirlist = ('sys$scratch:', $ENV{TMPDIR});
- {
- no strict 'refs';
- if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0
- require Scalar::Util;
- pop @dirlist if Scalar::Util::tainted($ENV{TMPDIR});
- }
- }
- foreach (@dirlist) {
- next unless defined && -d && -w _;
- $tmpdir = $_;
- last;
- }
- $tmpdir = File::Spec->curdir unless defined $tmpdir;
- return $tmpdir;
+ my $self = shift;
+ $tmpdir = $self->_tmpdir( 'sys$scratch:', $ENV{TMPDIR} );
}
=item updir (override)
use strict;
use Cwd;
+
use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '1.3';
+$VERSION = '1.4';
@ISA = qw(File::Spec::Unix);
/tmp
/
-The SYS:/temp is preferred in Novell NetWare.
+The SYS:/temp is preferred in Novell NetWare (the File::Spec::Win32
+is used also for NetWare).
Since Perl 5.8.0, if running under taint mode, and if the environment
variables are tainted, they are not used.
sub tmpdir {
return $tmpdir if defined $tmpdir;
my $self = shift;
- my @dirlist = (@ENV{qw(TMPDIR TEMP TMP)}, qw(C:/temp /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 = $self->canonpath($tmpdir);
- return $tmpdir;
+ $tmpdir = $self->_tmpdir( @ENV{qw(TMPDIR TEMP TMP)},
+ 'SYS:/temp',
+ 'C:/temp',
+ '/tmp',
+ '/' );
}
sub case_tolerant {