diff --git a/Docs/src/compilerflags.but b/Docs/src/compilerflags.but
index eb2cec54..ebbbdde2 100644
--- a/Docs/src/compilerflags.but
+++ b/Docs/src/compilerflags.but
@@ -34,9 +34,9 @@ This command sets the file date/time saving flag which is used by the File comma
\S2{asetoverwrite} SetOverwrite
-\c \\on\\|off|try|ifnewer|lastused
+\c \\on\\|off|try|ifnewer|ifdiff|lastused
-This command sets the overwrite flag which is used by the File command to determine whether or not the file should overwrite any existing files that are present. If overwriteflag is 'on', files are overwritten (this is the default). If overwriteflag is 'off', files that are already present are not overwritten. If overwriteflag is 'try', files are overwritten if possible (meaning that if the file is not able to be written to, it is skipped without any user interaction). If overwriteflag is 'ifnewer', then files are only overwritten if the existing file is older than the new file (note that when in 'ifnewer' mode, the destination file's date is set, regardless of what SetDateSave is set to).
+This command sets the overwrite flag which is used by the File command to determine whether or not the file should overwrite any existing files that are present. If overwriteflag is 'on', files are overwritten (this is the default). If overwriteflag is 'off', files that are already present are not overwritten. If overwriteflag is 'try', files are overwritten if possible (meaning that if the file is not able to be written to, it is skipped without any user interaction). If overwriteflag is 'ifnewer', then files are only overwritten if the existing file is older than the new file. If overwriteflag is 'ifdiff', then files are only overwritten if the existing file is older or newer than the new file. Note that when in 'ifnewer' or 'ifdiff' mode, the destination file's date is set, regardless of what SetDateSave is set to.
\S2{setpluginunload} SetPluginUnload
diff --git a/Docs/src/ui.but b/Docs/src/ui.but
index d5a5c049..e9983901 100644
--- a/Docs/src/ui.but
+++ b/Docs/src/ui.but
@@ -88,9 +88,9 @@ Sets mode at which commands print their status. None has commands be quiet, list
\S2{setctlcolors} SetCtlColors
-\c hwnd (branding | (text_color (transparent|bg_color)))
+\c hwnd [/BRANDING] [text_color] [transparent|bg_color]
-Sets a background color and the text color for a static control, edit control, button or a dialog. Use GetDlgItem to get the handle (HWND) of the control. To make the control transparent specify "transparent" as the background color value. You can also specify branding instead of text color and background color to make the control completely gray. This is used by the branding text control in the MUI.
+Sets a background color and the text color for a static control, edit control, button or a dialog. Use GetDlgItem to get the handle (HWND) of the control. To make the control transparent specify "transparent" as the background color value. You can also specify /BRANDING with or without text color and background color to make the control completely gray (or any other color you choose). This is used by the branding text control in the MUI.
\S2{setsilent} SetSilent
diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c
index 72f29f41..9f774cc3 100644
--- a/Source/exehead/exec.c
+++ b/Source/exehead/exec.c
@@ -366,11 +366,10 @@ static int NSISCALL ExecuteEntry(entry *entry_)
{
HANDLE hOut;
int ret;
- char *buf3=GetStringFromParm(0x31);
- #define overwriteflag parm0
+ char *buf3 = GetStringFromParm(0x31);
+ int overwriteflag = parm0 & 7;
- // Modified by ramon 23 May 2003
- log_printf4("File: overwriteflag=%d, allowskipfilesflag=%d, name=\"%s\"",overwriteflag,(parm0>>2)&MB_ABORTRETRYIGNORE,buf3);
+ log_printf4("File: overwriteflag=%d, allowskipfilesflag=%d, name=\"%s\"",overwriteflag,(parm0>>3)&MB_ABORTRETRYIGNORE,buf3);
if (validpathspec(buf3))
{
mystrcpy(buf0,buf3);
@@ -378,14 +377,16 @@ static int NSISCALL ExecuteEntry(entry *entry_)
else lstrcat(addtrailingslash(mystrcpy(buf0,state_output_directory)),buf3);
validate_filename(buf0);
_tryagain:
- if (overwriteflag == 3) // check date and time
+ if (overwriteflag >= 3) // check date and time
{
WIN32_FIND_DATA *ffd=file_exists(buf0);
- overwriteflag=1; // if it doesn't exist, fall back to no overwrites (since it shouldn't matter anyway)
if (ffd)
{
- overwriteflag=(CompareFileTime(&ffd->ftLastWriteTime,(FILETIME*)(entry_->offsets+3)) >= 0); // if first one is newer, then don't overwrite
+ // if first one is newer, then don't overwrite
+ int cmp=CompareFileTime(&ffd->ftLastWriteTime, (FILETIME*)(entry_->offsets + 3));
+ overwriteflag=!(cmp & (0x80000000 | (overwriteflag - 3)));
}
+ // if it doesn't exist, overwrite flag won't matter. it stays on off though.
}
if (!overwriteflag)
{
@@ -411,7 +412,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
mystrcpy(g_usrvars[0],buf2); // restore $0
// Modified by ramon 23 May 2003
- switch (my_MessageBox(buf1, parm0>>2))
+ switch (my_MessageBox(buf1, parm0>>3))
{
case IDRETRY:
log_printf("File: error, user retry");
@@ -456,10 +457,6 @@ static int NSISCALL ExecuteEntry(entry *entry_)
my_MessageBox(buf0,MB_OK|MB_ICONSTOP);
return EXEC_ERROR;
}
-
- #undef overwriteflag
- // Added by ramon 23 May 2003
- #undef allowskipfilesflag
}
break;
#endif//NSIS_SUPPORT_FILE
diff --git a/Source/script.cpp b/Source/script.cpp
index 0871c2e3..d10f3939 100644
--- a/Source/script.cpp
+++ b/Source/script.cpp
@@ -2695,9 +2695,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return PS_OK;
case TOK_SETOVERWRITE:
{
- int k=line.gettoken_enum(1,"on\0off\0try\0ifnewer\0lastused\0");
+ int k=line.gettoken_enum(1,"on\0off\0try\0ifnewer\0ifdiff\0lastused\0");
if (k==-1) PRINTHELP()
- if (k==4)
+ if (k==5)
{
k=build_overwrite;
build_overwrite=build_last_overwrite;
@@ -4882,7 +4882,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
DefineInnerLangString(NLF_CANT_WRITE);
ent.offsets[0]=1; // overwrite off
- ent.offsets[0]|=(MB_ABORTRETRYIGNORE|MB_ICONSTOP)<<2;
+ ent.offsets[0]|=(MB_ABORTRETRYIGNORE|MB_ICONSTOP)<<3;
ent.offsets[1]=add_string(tempDLL);
ent.offsets[2]=data_handle;
ent.offsets[3]=0xffffffff;
@@ -5121,7 +5121,7 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
if (generatecode)
{
- if (build_datesave || build_overwrite==0x3 /*ifnewer*/)
+ if (build_datesave || build_overwrite>=0x3 /*ifnewer or ifdiff*/)
{
FILETIME ft;
if (GetFileTime(hFile,NULL,NULL,&ft))
@@ -5143,7 +5143,7 @@ int CEXEBuild::do_add_file(const char *lgss, int attrib, int recurse, int linecn
}
// overwrite flag can be 0, 1, 2 or 3. in all cases, 2 bits
- ent.offsets[0] |= ((build_allowskipfiles ? MB_ABORTRETRYIGNORE : MB_RETRYCANCEL) | MB_ICONSTOP) << 2;
+ ent.offsets[0] |= ((build_allowskipfiles ? MB_ABORTRETRYIGNORE : MB_RETRYCANCEL) | MB_ICONSTOP) << 3;
ent.offsets[5] = DefineInnerLangString(build_allowskipfiles ? NLF_FILE_ERROR : NLF_FILE_ERROR_NOIGNORE);
}
diff --git a/Source/tokens.cpp b/Source/tokens.cpp
index c606592c..7bfbb379 100644
--- a/Source/tokens.cpp
+++ b/Source/tokens.cpp
@@ -163,7 +163,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_SETFILEATTRIBUTES,"SetFileAttributes",2,0,"file attribute[|attribute[...]]\n attribute=(NORMAL|ARCHIVE|HIDDEN|OFFLINE|READONLY|SYSTEM|TEMPORARY|0)"},
{TOK_SETFONT,"SetFont",2,1,"[/LANG=lang_id] font_face_name font_size"},
{TOK_SETOUTPATH,"SetOutPath",1,0,"output_path"},
-{TOK_SETOVERWRITE,"SetOverwrite",1,0,"(on|off|try|ifnewer)"},
+{TOK_SETOVERWRITE,"SetOverwrite",1,0,"on|off|try|ifnewer|ifdiff"},
{TOK_SETPLUGINUNLOAD,"SetPluginUnload",1,0,"(manual|alwaysoff)"},
{TOK_SETREBOOTFLAG,"SetRebootFlag",1,0,"true|false"},
{TOK_SETSHELLVARCONTEXT,"SetShellVarContext",1,0,"all|current"},