mirror of https://gitlab.com/basile.b/dexed.git
updated cleaner example project
This commit is contained in:
parent
ca977f3368
commit
c1d1b2c30c
|
@ -13,11 +13,13 @@ object CurrentProject: TCEProject
|
||||||
postBuildProcess.executable = '<CAP>cleaner.exe'
|
postBuildProcess.executable = '<CAP>cleaner.exe'
|
||||||
postBuildProcess.options = [poUsePipes, poStderrToOutPut]
|
postBuildProcess.options = [poUsePipes, poStderrToOutPut]
|
||||||
postBuildProcess.parameters.Strings = (
|
postBuildProcess.parameters.Strings = (
|
||||||
'-r'
|
|
||||||
'-f'
|
|
||||||
'<CAP>'
|
|
||||||
'-e'
|
'-e'
|
||||||
'.tmp,.res'
|
'.tmp,.res'
|
||||||
|
'-f'
|
||||||
|
'afile.file,anotherfile.hji'
|
||||||
|
'-p'
|
||||||
|
'<CAP>'
|
||||||
|
'-r'
|
||||||
)
|
)
|
||||||
postBuildProcess.showWindow = swoHIDE
|
postBuildProcess.showWindow = swoHIDE
|
||||||
runOptions.options = []
|
runOptions.options = []
|
||||||
|
|
|
@ -6,32 +6,42 @@ import std.file;
|
||||||
import std.getopt;
|
import std.getopt;
|
||||||
import std.array;
|
import std.array;
|
||||||
|
|
||||||
//as a runnable: -f "dir" -r -e ".ext1,.ext2"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
as a post-build process, parameter list:
|
|
||||||
-f
|
as a runnable, input query line:
|
||||||
pathtoclean (w/o dbl quotes)
|
|
||||||
-r
|
-e ".ext1,.ext2" -f "file.ext,file.ext" -p "rootPath" -r
|
||||||
-e
|
|
||||||
.a,.b,.c
|
or as a post-build process, parameter list:
|
||||||
|
|
||||||
|
-e
|
||||||
|
".ext1,.ext2"
|
||||||
|
-f
|
||||||
|
"file.ext,file.ext"
|
||||||
|
-p
|
||||||
|
"rootPath"
|
||||||
|
-r
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void main(string args[])
|
void main(string args[])
|
||||||
{
|
{
|
||||||
bool recursive;
|
bool recursive;
|
||||||
string root;
|
string path;
|
||||||
string userexts;
|
string userexts;
|
||||||
|
string userfiles;
|
||||||
string exts[];
|
string exts[];
|
||||||
|
string files[];
|
||||||
|
|
||||||
exts ~= [".obj", ".o"];
|
exts ~= [".obj", ".o"];
|
||||||
|
|
||||||
getopt(args, config.passThrough,
|
getopt(args, config.passThrough,
|
||||||
"f|from", &root,
|
"e|ext", &userexts,
|
||||||
"r|recursive", &recursive,
|
"f|files", &userfiles,
|
||||||
"e|ext", &userexts
|
"p|path", &path,
|
||||||
|
"r|recursive", &recursive
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!exists(root) || root.length == 0)
|
if (!exists(path) || path.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (userexts.length != 0)
|
if (userexts.length != 0)
|
||||||
|
@ -42,6 +52,14 @@ void main(string args[])
|
||||||
exts ~= itm;
|
exts ~= itm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userfiles.length != 0)
|
||||||
|
{
|
||||||
|
auto itms = split(userfiles, ',');
|
||||||
|
foreach(itm; itms)
|
||||||
|
if (itm.length > 0)
|
||||||
|
files ~= itm;
|
||||||
|
}
|
||||||
|
|
||||||
void clean(in string currroot)
|
void clean(in string currroot)
|
||||||
{
|
{
|
||||||
DirIterator entries = dirEntries(currroot, SpanMode.shallow);
|
DirIterator entries = dirEntries(currroot, SpanMode.shallow);
|
||||||
|
@ -55,11 +73,14 @@ void main(string args[])
|
||||||
foreach(trg_ext; exts)
|
foreach(trg_ext; exts)
|
||||||
if (entry.extension == trg_ext)
|
if (entry.extension == trg_ext)
|
||||||
std.file.remove(entry);
|
std.file.remove(entry);
|
||||||
|
foreach(trg_file; files)
|
||||||
|
if (entry.name == trg_file)
|
||||||
|
std.file.remove(entry);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (recursive)
|
else if (recursive)
|
||||||
clean(entry);
|
clean(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
clean(path);
|
||||||
clean(root);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue