Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add &dir
  • Loading branch information
sorear committed Aug 21, 2011
1 parent a014f92 commit 5b8523c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/Builtins.cs
Expand Up @@ -2187,4 +2187,15 @@ class CrossSource: ItemSource {
}
return ret;
}

public static Variable dir(string s) {
string[] raw = Directory.GetFileSystemEntries(s);
string[] forperl = new string[raw.Length + 2];
forperl[0] = "."; forperl[1] = "..";
for (int i = 0; i < raw.Length; i++) {
int ix = raw[i].LastIndexOf(Path.DirectorySeparatorChar);
forperl[i+2] = (ix >= 0) ? raw[i].Substring(ix+1) : raw[i];
}
return BoxLoS(forperl);
}
}
4 changes: 4 additions & 0 deletions lib/CORE.setting
Expand Up @@ -1908,6 +1908,10 @@ sub slurp($path) is unsafe { Q:CgOp { (box Str (slurp (unbox str (@ {$path}))))
sub spew($path,$text) is unsafe { Q:CgOp { (rnull (spew (unbox str (@ {$path.Str})) (unbox str (@ {$text.Str})))) } }
sub dir($directory = '.', Mu :$test = none('.','..')) is unsafe {
grep $test, Q:CgOp { (dir (obj_getstr {$directory})) };
}
my class Instant {
has $.val;
method to-posix() { ($!val, False) }
Expand Down

0 comments on commit 5b8523c

Please sign in to comment.