diff --git a/lazproj/test/coeditproj/cleaner.coedit b/lazproj/test/coeditproj/cleaner.coedit index 07ff3ab0..b4de1ab7 100644 --- a/lazproj/test/coeditproj/cleaner.coedit +++ b/lazproj/test/coeditproj/cleaner.coedit @@ -13,11 +13,13 @@ object CurrentProject: TCEProject postBuildProcess.executable = 'cleaner.exe' postBuildProcess.options = [poUsePipes, poStderrToOutPut] postBuildProcess.parameters.Strings = ( - '-r' - '-f' - '' '-e' '.tmp,.res' + '-f' + 'afile.file,anotherfile.hji' + '-p' + '' + '-r' ) postBuildProcess.showWindow = swoHIDE runOptions.options = [] diff --git a/lazproj/test/src/cleaner.d b/lazproj/test/src/cleaner.d index 1d395d72..595e5c9f 100644 --- a/lazproj/test/src/cleaner.d +++ b/lazproj/test/src/cleaner.d @@ -6,32 +6,42 @@ import std.file; import std.getopt; import std.array; -//as a runnable: -f "dir" -r -e ".ext1,.ext2" - /* -as a post-build process, parameter list: --f -pathtoclean (w/o dbl quotes) --r --e -.a,.b,.c + +as a runnable, input query line: + + -e ".ext1,.ext2" -f "file.ext,file.ext" -p "rootPath" -r + +or as a post-build process, parameter list: + + -e + ".ext1,.ext2" + -f + "file.ext,file.ext" + -p + "rootPath" + -r + */ void main(string args[]) { bool recursive; - string root; + string path; string userexts; + string userfiles; string exts[]; + string files[]; exts ~= [".obj", ".o"]; getopt(args, config.passThrough, - "f|from", &root, - "r|recursive", &recursive, - "e|ext", &userexts + "e|ext", &userexts, + "f|files", &userfiles, + "p|path", &path, + "r|recursive", &recursive ); - if (!exists(root) || root.length == 0) + if (!exists(path) || path.length == 0) return; if (userexts.length != 0) @@ -42,6 +52,14 @@ void main(string args[]) exts ~= itm; } + if (userfiles.length != 0) + { + auto itms = split(userfiles, ','); + foreach(itm; itms) + if (itm.length > 0) + files ~= itm; + } + void clean(in string currroot) { DirIterator entries = dirEntries(currroot, SpanMode.shallow); @@ -55,11 +73,14 @@ void main(string args[]) foreach(trg_ext; exts) if (entry.extension == trg_ext) std.file.remove(entry); + foreach(trg_file; files) + if (entry.name == trg_file) + std.file.remove(entry); + } else if (recursive) clean(entry); } } - - clean(root); + clean(path); }