for File::Temp::tempdir(CLEANUP => 1)
[p5sagit/p5-mst-13.2.git] / lib / Cwd.pm
index 2b5f85e..984375f 100644 (file)
@@ -138,8 +138,6 @@ L<File::chdir>
 
 use strict;
 
-use Carp;
-
 our $VERSION = '2.08';
 
 use base qw/ Exporter /;
@@ -167,7 +165,7 @@ if ($^O eq 'os2' && defined &sys_cwd && defined &sys_abspath) {
 
 eval {
     require XSLoader;
-    no warnings 'redefine';
+    local $^W = 0;
     XSLoader::load('Cwd');
 };
 
@@ -360,7 +358,8 @@ sub _perl_abs_path
 
     unless (@cst = stat( $start ))
     {
-       carp "stat($start): $!";
+       require Carp;
+       Carp::carp ("stat($start): $!");
        return '';
     }
     $cwd = '';
@@ -372,12 +371,14 @@ sub _perl_abs_path
        local *PARENT;
        unless (opendir(PARENT, $dotdots))
        {
-           carp "opendir($dotdots): $!";
+           require Carp;
+           Carp::carp ("opendir($dotdots): $!");
            return '';
        }
        unless (@cst = stat($dotdots))
        {
-           carp "stat($dotdots): $!";
+           require Carp;
+           Carp::carp ("stat($dotdots): $!");
            closedir(PARENT);
            return '';
        }
@@ -391,7 +392,8 @@ sub _perl_abs_path
            {
                unless (defined ($dir = readdir(PARENT)))
                {
-                   carp "readdir($dotdots): $!";
+                   require Carp;
+                   Carp::carp ("readdir($dotdots): $!");
                    closedir(PARENT);
                    return '';
                }
@@ -423,10 +425,15 @@ sub fast_abs_path {
     ($path) = $path =~ /(.*)/;
     ($cwd)  = $cwd  =~ /(.*)/;
 
-    CORE::chdir($path) || croak "Cannot chdir to $path: $!";
+    if (!CORE::chdir($path)) {
+       require Carp;
+       Carp::croak ("Cannot chdir to $path: $!");
+    }
     my $realpath = getcwd();
-    -d $cwd && CORE::chdir($cwd) ||
-       croak "Cannot chdir back to $cwd: $!";
+    if (! ((-d $cwd) && (CORE::chdir($cwd)))) {
+       require Carp;
+       Carp::croak ("Cannot chdir back to $cwd: $!");
+    }
     $realpath;
 }
 
@@ -452,13 +459,17 @@ sub _vms_cwd {
 sub _vms_abs_path {
     return $ENV{'DEFAULT'} unless @_;
     my $path = VMS::Filespec::pathify($_[0]);
-    croak("Invalid path name $_[0]") unless defined $path;
+    if (! defined $path)
+       {
+       require Carp;
+       Carp::croak("Invalid path name $_[0]")
+       }
     return VMS::Filespec::rmsexpand($path);
 }
 
 sub _os2_cwd {
     $ENV{'PWD'} = `cmd /c cd`;
-    chop $ENV{'PWD'};
+    chomp $ENV{'PWD'};
     $ENV{'PWD'} =~ s:\\:/:g ;
     return $ENV{'PWD'};
 }
@@ -477,7 +488,7 @@ sub _win32_cwd {
 sub _dos_cwd {
     if (!defined &Dos::GetCwd) {
         $ENV{'PWD'} = `command /c cd`;
-        chop $ENV{'PWD'};
+        chomp $ENV{'PWD'};
         $ENV{'PWD'} =~ s:\\:/:g ;
     } else {
         $ENV{'PWD'} = Dos::GetCwd();
@@ -490,7 +501,7 @@ sub _qnx_cwd {
        local $ENV{CDPATH} = '';
        local $ENV{ENV} = '';
     $ENV{'PWD'} = `/usr/bin/fullpath -t`;
-    chop $ENV{'PWD'};
+    chomp $ENV{'PWD'};
     return $ENV{'PWD'};
 }
 
@@ -499,8 +510,13 @@ sub _qnx_abs_path {
        local $ENV{CDPATH} = '';
        local $ENV{ENV} = '';
     my $path = @_ ? shift : '.';
-    my $realpath=`/usr/bin/fullpath -t $path`;
-    chop $realpath;
+    local *REALPATH;
+
+    open(REALPATH, '-|', '/usr/bin/fullpath', '-t', $path) or
+      die "Can't open /usr/bin/fullpath: $!";
+    my $realpath = <REALPATH>;
+    close REALPATH;
+    chomp $realpath;
     return $realpath;
 }