Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix dir "/" (for new code)
  • Loading branch information
lizmat committed Nov 27, 2014
1 parent 942ffba commit 8bbcb2f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/core/IO.pm
Expand Up @@ -54,8 +54,9 @@ sub MAKE-CLEAN-PARTS(Str $abspath) {

# handle //unc/ on win
@parts.unshift( @parts.splice(0,3).join('/') )
if @parts.at_pos(1) eq '' # //
and @parts.at_pos(0) eq ''; # and no C: like stuff
if @parts.elems >= 3 # //unc
&& @parts.at_pos(1) eq '' # //
&& @parts.at_pos(0) eq ''; # and no C: like stuff

# front part cleanup
@parts.splice(1,1)
Expand Down Expand Up @@ -107,8 +108,10 @@ sub MAKE-CLEAN-PARTS(Str $abspath) {
}
}

# need / at the end
@parts.push("");
# need (at least) / at the end
my $elems := @parts.elems;
@parts.push("") if $elems == 1 || @parts.at_pos($elems - 1) ne "";
@parts;
}

sub REMOVE-ROOT(Str $r, Str $p) {
Expand Down Expand Up @@ -360,7 +363,7 @@ sub MAKE-DIR-LIST(Str $abspath, Mu $test) {
} }

my str $cwd = nqp::cwd();
nqp::chdir(nqp::unbox_s($abspath.chop));
nqp::chdir(nqp::unbox_s($abspath));
my Mu $dirh := nqp::opendir(nqp::unbox_s($abspath));
nqp::chdir($cwd);

Expand Down Expand Up @@ -398,7 +401,7 @@ sub MAKE-DIR-LIST(Str $abspath, Mu $test) {
:path(nqp::box_s($abspath,Str)), :os-error(.Str) );
} }

my Mu $dirh := nqp::opendir(nqp::unbox_s($abspath.chop));
my Mu $dirh := nqp::opendir(nqp::unbox_s($abspath));
gather {
if $test.defined {
for <. ..> -> $elem {
Expand Down

0 comments on commit 8bbcb2f

Please sign in to comment.