on dosish platforms, avoid infinite recursion in File::Path::mkpath()
authorGurusamy Sarathy <gsar@cpan.org>
Sun, 5 Dec 1999 09:01:19 +0000 (09:01 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Sun, 5 Dec 1999 09:01:19 +0000 (09:01 +0000)
when given non-existent drive names

p4raw-id: //depot/perl@4651

lib/File/Path.pm

index a82fd80..634b2cd 100644 (file)
@@ -126,13 +126,15 @@ sub mkpath {
        my $parent = File::Basename::dirname($path);
        # Allow for creation of new logical filesystems under VMS
        if (not $Is_VMS or $parent !~ m:/[^/]+/000000/?:) {
-           push(@created,mkpath($parent, $verbose, $mode)) unless (-d $parent);
+           unless (-d $parent or $path eq $parent) {
+               push(@created,mkpath($parent, $verbose, $mode));
+           }
        }
        print "mkdir $path\n" if $verbose;
        unless (mkdir($path,$mode)) {
-         my $e = $!;
-         # allow for another process to have created it meanwhile
-         croak "mkdir $path: $e" unless -d $path;
+           my $e = $!;
+           # allow for another process to have created it meanwhile
+           croak "mkdir $path: $e" unless -d $path;
        }
        push(@created, $path);
     }