diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index fe5ffae6..31599f8e 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -537,7 +537,7 @@ static int NSISCALL ExecuteEntry(entry *entry_) if (lastchar(buf0)=='\\') trimslashtoend(buf0); doRMDir(buf0,parm1); - if (file_exists(buf0)) g_flags.exec_error++; + if (file_exists(buf0) && parm1!=2) g_flags.exec_error++; } return 0; #endif//NSIS_SUPPORT_RMDIR diff --git a/Source/exehead/util.c b/Source/exehead/util.c index d3b52f2c..2918d712 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -73,11 +73,11 @@ void * NSISCALL my_GlobalAlloc(DWORD dwBytes) { } #ifdef NSIS_SUPPORT_RMDIR -void NSISCALL doRMDir(char *buf, int recurse) +void NSISCALL doRMDir(char *buf, int flags) // 1 - recurse, 2 - rebootok { if (is_valid_instpath(buf)) { - if (recurse) { + if (flags&1) { SHFILEOPSTRUCT op; op.hwnd=0; @@ -90,7 +90,17 @@ void NSISCALL doRMDir(char *buf, int recurse) SHFileOperation(&op); } +#ifdef NSIS_SUPPORT_MOVEONREBOOT + else if (!RemoveDirectory(buf) && flags&2) { + log_printf2("Remove folder on reboot: %s",buf); +#ifdef NSIS_SUPPORT_REBOOT + g_flags.exec_reboot++; +#endif + MoveFileOnReboot(buf,0); + } +#else else RemoveDirectory(buf); +#endif } log_printf2("RMDir: RemoveDirectory(\"%s\")",buf); update_status_text_from_lang(LANG_REMOVEDIR,buf); diff --git a/Source/script.cpp b/Source/script.cpp index e0ad7585..ca481c57 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -3021,9 +3021,15 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char a++; ent.offsets[1]=1; } + else if (!stricmp(line.gettoken_str(1),"/REBOOTOK")) + { + if (line.getnumtokens() < 3) PRINTHELP() + a++; + ent.offsets[1]=2; + } else if (line.gettoken_str(1)[0]=='/') PRINTHELP() ent.offsets[0]=add_string(line.gettoken_str(a)); - SCRIPT_MSG("RMDir: %s\"%s\"\n",ent.offsets[1]?"/r " : "",line.gettoken_str(a)); + SCRIPT_MSG("RMDir: %s%s\"%s\"\n",a==1?"":line.gettoken_str(1),ent.offsets[1]?" ":"",line.gettoken_str(a)); } return add_entry(&ent); #else//!NSIS_SUPPORT_RMDIR diff --git a/Source/tokens.cpp b/Source/tokens.cpp index b1ab387c..53849bf1 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -124,7 +124,7 @@ static tokenType tokenlist[TOK__LAST] = {TOK_REGDLL,"RegDLL",1,1,"dll_path_on_target.dll [entrypoint_symbol]"}, {TOK_RENAME,"Rename",2,1,"[/REBOOTOK] source_file destination_file"}, {TOK_RET,"Return",0,0,""}, -{TOK_RMDIR,"RMDir",1,1,"[/r] directory_name"}, +{TOK_RMDIR,"RMDir",1,1,"[/r|/REBOOTOK] directory_name"}, {TOK_SECTION,"Section",0,3,"[/e] [section_name|-section_name] [section index output]"}, {TOK_SUBSECTION,"SubSection",1,2,"[/e] subsection_name [section index output]"}, {TOK_SUBSECTIONEND,"SubSectionEnd",0,0,""},