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,
|
||||
|
@@ -9,16 +9,6 @@
|
||||
(var &mut builtinConfigDir "")
|
||||
(var &mut :KissConfig config null)
|
||||
|
||||
(function walkDirectory [basePath directory :String->Void processFile :String->Void processSubdirectory]
|
||||
(doFor fileOrFolder (FileSystem.readDirectory (joinPath basePath directory))
|
||||
(case fileOrFolder
|
||||
((when (FileSystem.isDirectory (joinPath basePath directory folder)) folder)
|
||||
(let [subdirectory (joinPath directory folder)]
|
||||
(processSubdirectory subdirectory)
|
||||
(walkDirectory basePath subdirectory processFile processSubdirectory)))
|
||||
(file
|
||||
(processFile (joinPath directory file))))))
|
||||
|
||||
(function :Void tryLoadConfig [&opt :String text]
|
||||
// TODO if a config object is active and a shortcut panel is open, dispose the panel before we lose the handle in the current config object
|
||||
|
||||
|
Reference in New Issue
Block a user