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

Closed
wants to merge 2 commits into
from

Projects

None yet

3 participants

@sergot
Member
sergot commented Jun 24, 2012

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 Jun 24, 2012
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 Jun 24, 2012

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

@labster
Member
labster commented May 31, 2013

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

@labster labster closed this May 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment