purgeDirectory
This commit is contained in:
@@ -78,6 +78,7 @@ class Kiss {
|
||||
"assertProcess" => Symbol("Prelude.assertProcess"),
|
||||
"random" => Symbol("Std.random"),
|
||||
"walkDirectory" => Symbol("Prelude.walkDirectory"),
|
||||
"purgeDirectory" => Symbol("Prelude.purgeDirectory"),
|
||||
"getTarget" => Symbol("Prelude.getTarget"),
|
||||
// These work with (apply) because they are added as "opAliases" in Macros.kiss:
|
||||
"min" => Symbol("Prelude.min"),
|
||||
|
@@ -409,11 +409,13 @@ class Prelude {
|
||||
switch (fileOrFolder) {
|
||||
case folder if (FileSystem.isDirectory(joinPath(basePath, directory, folder))):
|
||||
var subdirectory = joinPath(directory, folder);
|
||||
if (processFolderBefore != null)
|
||||
if (processFolderBefore != null) {
|
||||
processFolderBefore(subdirectory);
|
||||
}
|
||||
walkDirectory(basePath, subdirectory, processFile, processFolderBefore, processFolderAfter);
|
||||
if (processFolderAfter != null)
|
||||
if (processFolderAfter != null) {
|
||||
processFolderAfter(subdirectory);
|
||||
}
|
||||
case file:
|
||||
processFile(joinPath(directory, file));
|
||||
}
|
||||
@@ -423,6 +425,15 @@ class Prelude {
|
||||
#end
|
||||
}
|
||||
|
||||
public static function purgeDirectory(directory) {
|
||||
#if (sys || hxnodejs)
|
||||
walkDirectory("", directory, FileSystem.deleteFile, null, FileSystem.deleteDirectory);
|
||||
FileSystem.deleteDirectory(directory);
|
||||
#else
|
||||
throw "Can't delete files/folders 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