Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[src/core/IO.pm] nicer &dir #72

Closed
wants to merge 2 commits into from

3 participants

@sergot
Collaborator

No change 'inside', only 'outside'. Works the same way.
'/' is unnecessary in particular calls.

before:

.Str.say for dir './'
.//file2
.//file1
.//dir2
.//dir1

after:

.Str.say for dir './'
./file2
./file1
./dir2
./dir1

@ajs ajs commented on the diff
src/core/IO.pm
@@ -316,7 +316,7 @@ sub dir($path = '.', Mu :$test = none('.', '..')) {
my @res;
loop (my int $i = 0; $i < $elems; $i = $i + 1) {
my Str $file := nqp::p6box_s(nqp::atpos($RSA, $i));
- @res.push: "$path/$file".IO if $test.ACCEPTS($file);
+ @res.push: ($path.substr(*-1) eq '/' ?? "$path$file" !! "$path/$file").IO if $test.ACCEPTS($file);
@ajs
ajs added a note

What w really need, here, is a File::Path module, but this change is a reasonable fix for the immediate problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@labster
Collaborator

Replaced by IO::Spec/IO::Path stuff, long after this pull request was sent. Closing ticket.

@labster labster closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 24, 2012
  1. @sergot

    [src/core/IO.pm] nicer &dir

    sergot authored
  2. @sergot

    regex changed to .substr

    sergot authored
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  src/core/IO.pm
View
2  src/core/IO.pm
@@ -316,7 +316,7 @@ sub dir($path = '.', Mu :$test = none('.', '..')) {
my @res;
loop (my int $i = 0; $i < $elems; $i = $i + 1) {
my Str $file := nqp::p6box_s(nqp::atpos($RSA, $i));
- @res.push: "$path/$file".IO if $test.ACCEPTS($file);
+ @res.push: ($path.substr(*-1) eq '/' ?? "$path$file" !! "$path/$file").IO if $test.ACCEPTS($file);
@ajs
ajs added a note

What w really need, here, is a File::Path module, but this change is a reasonable fix for the immediate problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
return @res;
Something went wrong with that request. Please try again.