dist/PathTools/t/abs2rel.t See if File::Spec->abs2rel works
dist/PathTools/t/crossplatform.t See if File::Spec works crossplatform
dist/PathTools/t/cwd.t See if Cwd works
+dist/PathTools/t/cwd_enoent.t See if getcwd errors correctly
dist/PathTools/t/Functions.t See if File::Spec::Functions works
dist/PathTools/t/rel2abs2rel.t See if File::Spec->rel2abs/abs2rel works
dist/PathTools/t/Spec.t See if File::Spec works
use Exporter;
-our $VERSION = '3.71';
+our $VERSION = '3.72';
my $xs_version = $VERSION;
$VERSION =~ tr/_//d;
unless (@cst = stat( $start ))
{
- _carp("stat($start): $!");
- return '';
+ return undef;
}
unless (-d _) {
}
unless (@cst = stat($dotdots))
{
- _carp("stat($dotdots): $!");
+ my $e = $!;
closedir(PARENT);
- return '';
+ $! = $e;
+ return undef;
}
if ($pst[0] == $cst[0] && $pst[1] == $cst[1])
{
{
unless (defined ($dir = readdir(PARENT)))
{
- _carp("readdir($dotdots): $!");
closedir(PARENT);
- return '';
+ require Errno;
+ $! = Errno::ENOENT();
+ return undef;
}
$tst[0] = $pst[0]+1 unless (@tst = lstat("$dotdots/$dir"))
}
my $cwd = getcwd();
-Returns the current working directory.
+Returns the current working directory. On error returns C<undef>,
+with C<$!> set to indicate the error.
Exposes the POSIX function getcwd(3) or re-implements it if it's not
available.
Uses the same algorithm as getcwd(). Symbolic links and relative-path
components ("." and "..") are resolved to return the canonical
-pathname, just like realpath(3).
+pathname, just like realpath(3). On error returns C<undef>, with C<$!>
+set to indicate the error.
=item realpath
use strict;
-our $VERSION = '3.71';
+our $VERSION = '3.72';
$VERSION =~ tr/_//d;
my %module = (
use strict;
require File::Spec::Unix;
-our $VERSION = '3.71';
+our $VERSION = '3.72';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
use strict;
require File::Spec::Unix;
-our $VERSION = '3.71';
+our $VERSION = '3.72';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
use strict;
-our $VERSION = '3.71';
+our $VERSION = '3.72';
$VERSION =~ tr/_//d;
require File::Spec::Unix;
use File::Spec;
use strict;
-our $VERSION = '3.71';
+our $VERSION = '3.72';
$VERSION =~ tr/_//d;
require Exporter;
use Cwd ();
require File::Spec::Unix;
-our $VERSION = '3.71';
+our $VERSION = '3.72';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
use Cwd ();
require File::Spec::Unix;
-our $VERSION = '3.71';
+our $VERSION = '3.72';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
use strict;
use Cwd ();
-our $VERSION = '3.71';
+our $VERSION = '3.72';
$VERSION =~ tr/_//d;
=head1 NAME
use Cwd ();
require File::Spec::Unix;
-our $VERSION = '3.71';
+our $VERSION = '3.72';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
use Cwd ();
require File::Spec::Unix;
-our $VERSION = '3.71';
+our $VERSION = '3.72';
$VERSION =~ tr/_//d;
our @ISA = qw(File::Spec::Unix);
--- /dev/null
+use warnings;
+use strict;
+
+use Config;
+use Errno qw(ENOENT);
+use File::Temp qw(tempdir);
+use Test::More;
+
+my $tmp = tempdir(CLEANUP => 1);
+unless(mkdir("$tmp/testdir") && chdir("$tmp/testdir") && rmdir("$tmp/testdir")){
+ plan skip_all => "can't be in non-existent directory";
+}
+
+plan tests => 8;
+my $EXTRA_ABSPATH_TESTS = ($Config{prefix} =~ m/\//) && $^O ne 'cygwin';
+require Cwd;
+
+foreach my $type (qw(regular perl)) {
+ SKIP: {
+ skip "_perl_abs_path() not expected to work", 4
+ if $type eq "perl" &&
+ !(($Config{prefix} =~ m/\//) && $^O ne "cygwin");
+ no warnings "redefine";
+ local *Cwd::abs_path = \&Cwd::_perl_abs_path if $type eq "perl";
+ local *Cwd::getcwd = \&Cwd::_perl_getcwd if $type eq "perl";
+ my($res, $eno);
+ $! = 0;
+ $res = Cwd::getcwd();
+ $eno = 0+$!;
+ is $res, undef, "$type getcwd result on non-existent directory";
+ is $eno, ENOENT, "$type getcwd errno on non-existent directory";
+ $! = 0;
+ $res = Cwd::abs_path(".");
+ $eno = 0+$!;
+ is $res, undef, "$type abs_path result on non-existent directory";
+ is $eno, ENOENT, "$type abs_path errno on non-existent directory";
+ }
+}
+
+chdir $tmp or die "$tmp: $!";
+
+1;