free CheckTree from the tyranny of the forward slash
Craig A. Berry [Thu, 11 Apr 2002 13:47:21 +0000 (08:47 -0500)]
From: "Craig A. Berry" <craigberry@mac.com>
Message-Id: <a05101500b8db89763fbf@[172.16.52.1]>

p4raw-id: //depot/perl@15866

lib/File/CheckTree.pm
lib/File/CheckTree.t

index 3da9f20..7884ca7 100644 (file)
@@ -1,8 +1,9 @@
 package File::CheckTree;
 
 use 5.006;
-use Exporter;
 use Cwd;
+use Exporter;
+use File::Spec;
 use warnings;
 use strict;
 
@@ -107,7 +108,8 @@ sub validate {
             my $this = $test;
 
             # expand relative $file to full pathname if preceded by cd directive
-            $file = $cwd . '/' . $file if $cwd && $file !~ m|^/|;
+            $file = File::Spec->catfile($cwd, $file) 
+                    if $cwd && !File::Spec->file_name_is_absolute($file);
 
             # put filename in after the test operator
             $this =~ s/(-\w\b)/$1 "\$file"/g;
index ae5a311..0257f4e 100755 (executable)
@@ -116,7 +116,7 @@ chdir(File::Spec->updir) or die "cannot change to parent of t/ directory: $!";
 # cd directive followed by relative paths, followed by full paths
 {
     my ($num_warnings, @warnings, $path_to_libFile, $path_to_dist);
-    $path_to_libFile = File::Spec->rel2abs('lib/File');
+    $path_to_libFile = File::Spec->rel2abs(File::Spec->catdir('lib','File'));
     $path_to_dist    = File::Spec->rel2abs(File::Spec->curdir);
 
     local $SIG{__WARN__} = sub { push @warnings, "@_" };