From: Ken Williams Date: Mon, 18 Aug 2003 17:07:43 +0000 (-0500) Subject: maintperl - File::Spec cwd() stuff X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f9fbf424fb61f97e6792e9a8ed040a85ffe5d3b2;p=p5sagit%2Fp5-mst-13.2.git maintperl - File::Spec cwd() stuff Message-Id: <645E5A7D-D1C8-11D7-84BF-003065F6D85A@mathforum.org> p4raw-id: //depot/perl@20770 --- diff --git a/lib/File/Spec/OS2.pm b/lib/File/Spec/OS2.pm index f323358..1418890 100644 --- a/lib/File/Spec/OS2.pm +++ b/lib/File/Spec/OS2.pm @@ -29,6 +29,11 @@ sub path { return @path; } +sub cwd { + require Cwd; + return Cwd::sys_cwd(); +} + =pod =item tmpdir @@ -200,8 +205,7 @@ sub abs2rel { # Figure out the effective $base and clean it up. if ( !defined( $base ) || $base eq '' ) { - require Cwd; - $base = Cwd::sys_cwd() ; + $base = $self->cwd(); } elsif ( ! $self->file_name_is_absolute( $base ) ) { $base = $self->rel2abs( $base ) ; } else { @@ -259,8 +263,7 @@ sub rel2abs { if ( ! $self->file_name_is_absolute( $path ) ) { if ( !defined( $base ) || $base eq '' ) { - require Cwd; - $base = Cwd::sys_cwd() ; + $base = $self->cwd(); } elsif ( ! $self->file_name_is_absolute( $base ) ) { $base = $self->rel2abs( $base ) ; diff --git a/lib/File/Spec/Unix.pm b/lib/File/Spec/Unix.pm index c76152b..703d23a 100644 --- a/lib/File/Spec/Unix.pm +++ b/lib/File/Spec/Unix.pm @@ -446,8 +446,7 @@ sub rel2abs { if ( ! $self->file_name_is_absolute( $path ) ) { # Figure out the effective $base and clean it up. if ( !defined( $base ) || $base eq '' ) { - require Cwd; - $base = Cwd::cwd() ; + $base = $self->cwd(); } elsif ( ! $self->file_name_is_absolute( $base ) ) { $base = $self->rel2abs( $base ) ; diff --git a/lib/File/Spec/t/Spec.t b/lib/File/Spec/t/Spec.t index 847d901..f3e49f0 100644 --- a/lib/File/Spec/t/Spec.t +++ b/lib/File/Spec/t/Spec.t @@ -214,6 +214,7 @@ if ($^O eq 'MacOS') { [ "Win32->canonpath('/a/b/c/../../d')", '\\a\\d' ], [ "Win32->canonpath('/a/b/c/.../d')", '\\a\\d' ], [ "Win32->canonpath('\\../temp\\')", '\\temp' ], +[ "Win32->can('cwd')", qr/CODE/ ], # FakeWin32 subclass (see below) just sets CWD to C:\one\two