implemented RFE #1505425 - !delfile wildcards and /nonfatal
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5979 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
4cbde48fe7
commit
46b88d766d
2 changed files with 51 additions and 11 deletions
|
@ -1165,15 +1165,55 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
|
|
||||||
case TOK_P_DELFILE:
|
case TOK_P_DELFILE:
|
||||||
{
|
{
|
||||||
char *file = line.gettoken_str(1);
|
int fatal = 1;
|
||||||
PATH_CONVERT(file);
|
int a = 1;
|
||||||
int result = unlink(file);
|
char *fc = line.gettoken_str(a);
|
||||||
if (result == -1) {
|
if (line.getnumtokens()==3)
|
||||||
ERROR_MSG("!delfile: \"%s\" couldn't be deleted.\n", line.gettoken_str(1));
|
{
|
||||||
return PS_ERROR;
|
if(!stricmp(fc,"/nonfatal"))
|
||||||
|
{
|
||||||
|
fatal = 0;
|
||||||
|
fc = line.gettoken_str(++a);
|
||||||
|
}
|
||||||
|
else PRINTHELP();
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_MSG("!delfile: \"%s\"\n", line.gettoken_str(1));
|
SCRIPT_MSG("!delfile: \"%s\"\n", line.gettoken_str(a));
|
||||||
|
|
||||||
|
string dir = get_dir_name(fc);
|
||||||
|
string spec = get_file_name(fc);
|
||||||
|
string basedir = dir + PLATFORM_PATH_SEPARATOR_STR;
|
||||||
|
if (dir == spec) {
|
||||||
|
// no path, just file name
|
||||||
|
dir = ".";
|
||||||
|
basedir = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::scoped_ptr<dir_reader> dr( new_dir_reader() );
|
||||||
|
dr->read(dir);
|
||||||
|
|
||||||
|
for (dir_reader::iterator files_itr = dr->files().begin();
|
||||||
|
files_itr != dr->files().end();
|
||||||
|
files_itr++)
|
||||||
|
{
|
||||||
|
if (!dir_reader::matches(*files_itr, spec))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string file = basedir + *files_itr;
|
||||||
|
|
||||||
|
int result = unlink(file.c_str());
|
||||||
|
if (result == -1) {
|
||||||
|
ERROR_MSG("!delfile: \"%s\" couldn't be deleted.\n", file.c_str());
|
||||||
|
if (fatal)
|
||||||
|
{
|
||||||
|
return PS_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SCRIPT_MSG("!delfile: deleted \"%s\"\n", file.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return PS_OK;
|
return PS_OK;
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,7 @@ static tokenType tokenlist[TOK__LAST] =
|
||||||
{TOK_P_IFMACRONDEF,"!ifmacrondef",1,-1,"macro [| macro2 [& macro3 [...]]]",TP_ALL},
|
{TOK_P_IFMACRONDEF,"!ifmacrondef",1,-1,"macro [| macro2 [& macro3 [...]]]",TP_ALL},
|
||||||
|
|
||||||
{TOK_P_TEMPFILE,"!tempfile",1,0,"symbol",TP_ALL},
|
{TOK_P_TEMPFILE,"!tempfile",1,0,"symbol",TP_ALL},
|
||||||
{TOK_P_DELFILE,"!delfile",1,0,"file",TP_ALL},
|
{TOK_P_DELFILE,"!delfile",1,1,"[/nonfatal] file",TP_ALL},
|
||||||
{TOK_P_APPENDFILE,"!appendfile",2,0,"file appended_line",TP_ALL},
|
{TOK_P_APPENDFILE,"!appendfile",2,0,"file appended_line",TP_ALL},
|
||||||
|
|
||||||
{TOK_P_SEARCHPARSESTRING,"!searchparse",3,-1,"[/ignorecase] [/noerrors] [/file] source_string substring OUTPUTSYM1 [substring [OUTPUTSYM2 [substring ...]]]",TP_ALL},
|
{TOK_P_SEARCHPARSESTRING,"!searchparse",3,-1,"[/ignorecase] [/noerrors] [/file] source_string substring OUTPUTSYM1 [substring [OUTPUTSYM2 [substring ...]]]",TP_ALL},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue