Browse files

Make dir return IO::Path objects.

  • Loading branch information...
1 parent 1bed6b7 commit 6e28e36485cd93b36c0895f120f57c943bf73965 @colomon colomon committed Jun 3, 2013
Showing with 5 additions and 2 deletions.
  1. +4 −2 lib/CORE.setting
  2. +1 −0 t/spectest.data
View
6 lib/CORE.setting
@@ -3744,7 +3744,9 @@ sub slurp($path?) is unsafe {
sub spurt($path,$text) is unsafe { Q:CgOp { (rnull (spurt (unbox str (@ {$path.Str})) (unbox str (@ {$text.Str})))) } }
sub dir($directory = '.', Mu :$test = none('.','..')) is unsafe {
- Q:CgOp { (dir (obj_getstr {$directory})) }.grep($test).map(*.path);
+ Q:CgOp { (dir (obj_getstr {$directory})) }.grep($test).map({
+ IO::Path.new(:$directory, :basename($_), :volume(""))
+ });
}
my class Instant {
@@ -3862,7 +3864,7 @@ class IO::Path is Cool does IO::FileTestable {
# react weirdly to '/'
if $path eq '/' {
self.bless(*, :basename(""),
- :directory("/"),
+ :directory($path),
:volume(""));
} else {
self.bless(*, :basename(Q:CgOp { (box Str (path_get_file_name (obj_getstr {$path}))) }),
View
1 t/spectest.data
@@ -499,6 +499,7 @@ S32-hash/pairs.t
S32-hash/push.t
S32-hash/slice.t
S32-io/chdir.t
+S32-io/dir.t
S32-io/file-tests.t
S32-io/io-path.t
S32-io/note.t

0 comments on commit 6e28e36

Please sign in to comment.