Close #40
This commit is contained in:
@@ -77,6 +77,7 @@ class Kiss {
|
||||
"enumerate" => Symbol("Prelude.enumerate"),
|
||||
"assertProcess" => Symbol("Prelude.assertProcess"),
|
||||
"random" => Symbol("Std.random"),
|
||||
"walkDirectory" => Symbol("Prelude.walkDirectory"),
|
||||
// These work with (apply) because they are added as "opAliases" in Macros.kiss:
|
||||
"min" => Symbol("Prelude.min"),
|
||||
"max" => Symbol("Prelude.max"),
|
||||
|
@@ -11,6 +11,9 @@ import js.node.Buffer;
|
||||
#elseif sys
|
||||
import sys.io.Process;
|
||||
#end
|
||||
#if (sys || hxnodejs)
|
||||
import sys.FileSystem;
|
||||
#end
|
||||
#if python
|
||||
import python.lib.subprocess.Popen;
|
||||
import python.Bytearray;
|
||||
@@ -373,6 +376,23 @@ class Prelude {
|
||||
private static var kissProcess:Process = null;
|
||||
#end
|
||||
|
||||
public static function walkDirectory(basePath, directory, processFile:(String) -> Void, processSubdirectory:(String) -> Void) {
|
||||
#if (sys || hxnodejs)
|
||||
for (fileOrFolder in FileSystem.readDirectory(joinPath(basePath, directory))) {
|
||||
switch (fileOrFolder) {
|
||||
case folder if (FileSystem.isDirectory(joinPath(basePath, directory, folder))):
|
||||
var subdirectory = joinPath(directory, folder);
|
||||
processSubdirectory(subdirectory);
|
||||
walkDirectory(basePath, subdirectory, processFile, processSubdirectory);
|
||||
case file:
|
||||
processFile(joinPath(directory, file));
|
||||
}
|
||||
}
|
||||
#else
|
||||
throw "Can't walk a directory on this target.";
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
* On Sys targets and nodejs, Kiss can be converted to hscript at runtime
|
||||
* NOTE on non-nodejs targets, after the first time calling this function,
|
||||
|
Reference in New Issue
Block a user