Alien-Selenium
view release on metacpan or search on metacpan
inc/File/Spec/Unix.pm view on Meta::CPAN
OS2. Of course, if this is the root directory, don't cut off the
trailing slash :-)
=cut
sub catdir {
my $self = shift;
$self->canonpath(join('/', @_, '')); # '' because need a trailing '/'
}
=item catfile
Concatenate one or more directory names and a filename to form a
complete path ending with a filename
=cut
sub catfile {
my $self = shift;
my $file = $self->canonpath(pop @_);
return $file unless @_;
my $dir = $self->catdir(@_);
$dir .= "/" unless substr($dir,-1) eq "/";
return $dir.$file;
}
=item curdir
Returns a string representation of the current directory. "." on UNIX.
=cut
sub curdir () { '.' }
=item devnull
Returns a string representation of the null device. "/dev/null" on UNIX.
=cut
sub devnull () { '/dev/null' }
=item rootdir
Returns a string representation of the root directory. "/" on UNIX.
=cut
sub rootdir () { '/' }
=item tmpdir
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
Since perl 5.8.0, if running under taint mode, and if $ENV{TMPDIR}
is tainted, it is not used.
=cut
my $tmpdir;
sub _tmpdir {
return $tmpdir if defined $tmpdir;
my $self = shift;
my @dirlist = @_;
{
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 && -w _;
$tmpdir = $_;
last;
}
$tmpdir = $self->curdir unless defined $tmpdir;
$tmpdir = defined $tmpdir && $self->canonpath($tmpdir);
return $tmpdir;
}
sub tmpdir {
return $tmpdir if defined $tmpdir;
my $self = shift;
$tmpdir = $self->_tmpdir( $ENV{TMPDIR}, "/tmp" );
}
=item updir
Returns a string representation of the parent directory. ".." on UNIX.
=cut
sub updir () { '..' }
=item no_upwards
Given a list of file names, strip out those that refer to a parent
directory. (Does not strip symlinks, only '.', '..', and equivalents.)
=cut
sub no_upwards {
my $self = shift;
return grep(!/^\.{1,2}\Z(?!\n)/s, @_);
}
=item case_tolerant
Returns a true or false value indicating, respectively, that alphabetic
is not or is significant when comparing file specifications.
=cut
sub case_tolerant () { 0 }
=item file_name_is_absolute
Takes as argument a path and returns true if it is an absolute path.
This does not consult the local filesystem on Unix, Win32, OS/2 or Mac
OS (Classic). It does consult the working environment for VMS (see
L<File::Spec::VMS/file_name_is_absolute>).
=cut
sub file_name_is_absolute {
my ($self,$file) = @_;
return scalar($file =~ m:^/:s);
( run in 0.351 second using v1.01-cache-2.11-cpan-0bd6704ced7 )