fixed SetOverwrite and added ifdiff option

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2876 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2003-09-07 16:46:50 +00:00
parent 6e5ed12086
commit 2fba235c29
5 changed files with 19 additions and 22 deletions

View file

@ -34,9 +34,9 @@ This command sets the file date/time saving flag which is used by the File comma
\S2{asetoverwrite} SetOverwrite \S2{asetoverwrite} SetOverwrite
\c \\<b\\>on\\</b\\>|off|try|ifnewer|lastused \c \\<b\\>on\\</b\\>|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 \S2{setpluginunload} SetPluginUnload

View file

@ -88,9 +88,9 @@ Sets mode at which commands print their status. None has commands be quiet, list
\S2{setctlcolors} SetCtlColors \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 \S2{setsilent} SetSilent

View file

@ -366,11 +366,10 @@ static int NSISCALL ExecuteEntry(entry *entry_)
{ {
HANDLE hOut; HANDLE hOut;
int ret; int ret;
char *buf3=GetStringFromParm(0x31); char *buf3 = GetStringFromParm(0x31);
#define overwriteflag parm0 int overwriteflag = parm0 & 7;
// Modified by ramon 23 May 2003 log_printf4("File: overwriteflag=%d, allowskipfilesflag=%d, name=\"%s\"",overwriteflag,(parm0>>3)&MB_ABORTRETRYIGNORE,buf3);
log_printf4("File: overwriteflag=%d, allowskipfilesflag=%d, name=\"%s\"",overwriteflag,(parm0>>2)&MB_ABORTRETRYIGNORE,buf3);
if (validpathspec(buf3)) if (validpathspec(buf3))
{ {
mystrcpy(buf0,buf3); mystrcpy(buf0,buf3);
@ -378,14 +377,16 @@ static int NSISCALL ExecuteEntry(entry *entry_)
else lstrcat(addtrailingslash(mystrcpy(buf0,state_output_directory)),buf3); else lstrcat(addtrailingslash(mystrcpy(buf0,state_output_directory)),buf3);
validate_filename(buf0); validate_filename(buf0);
_tryagain: _tryagain:
if (overwriteflag == 3) // check date and time if (overwriteflag >= 3) // check date and time
{ {
WIN32_FIND_DATA *ffd=file_exists(buf0); 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) 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) if (!overwriteflag)
{ {
@ -411,7 +412,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
mystrcpy(g_usrvars[0],buf2); // restore $0 mystrcpy(g_usrvars[0],buf2); // restore $0
// Modified by ramon 23 May 2003 // Modified by ramon 23 May 2003
switch (my_MessageBox(buf1, parm0>>2)) switch (my_MessageBox(buf1, parm0>>3))
{ {
case IDRETRY: case IDRETRY:
log_printf("File: error, user retry"); log_printf("File: error, user retry");
@ -456,10 +457,6 @@ static int NSISCALL ExecuteEntry(entry *entry_)
my_MessageBox(buf0,MB_OK|MB_ICONSTOP); my_MessageBox(buf0,MB_OK|MB_ICONSTOP);
return EXEC_ERROR; return EXEC_ERROR;
} }
#undef overwriteflag
// Added by ramon 23 May 2003
#undef allowskipfilesflag
} }
break; break;
#endif//NSIS_SUPPORT_FILE #endif//NSIS_SUPPORT_FILE

View file

@ -2695,9 +2695,9 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
return PS_OK; return PS_OK;
case TOK_SETOVERWRITE: 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==-1) PRINTHELP()
if (k==4) if (k==5)
{ {
k=build_overwrite; k=build_overwrite;
build_overwrite=build_last_overwrite; build_overwrite=build_last_overwrite;
@ -4882,7 +4882,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
DefineInnerLangString(NLF_CANT_WRITE); DefineInnerLangString(NLF_CANT_WRITE);
ent.offsets[0]=1; // overwrite off 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[1]=add_string(tempDLL);
ent.offsets[2]=data_handle; ent.offsets[2]=data_handle;
ent.offsets[3]=0xffffffff; 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 (generatecode)
{ {
if (build_datesave || build_overwrite==0x3 /*ifnewer*/) if (build_datesave || build_overwrite>=0x3 /*ifnewer or ifdiff*/)
{ {
FILETIME ft; FILETIME ft;
if (GetFileTime(hFile,NULL,NULL,&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 // 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); ent.offsets[5] = DefineInnerLangString(build_allowskipfiles ? NLF_FILE_ERROR : NLF_FILE_ERROR_NOIGNORE);
} }

View file

@ -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_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_SETFONT,"SetFont",2,1,"[/LANG=lang_id] font_face_name font_size"},
{TOK_SETOUTPATH,"SetOutPath",1,0,"output_path"}, {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_SETPLUGINUNLOAD,"SetPluginUnload",1,0,"(manual|alwaysoff)"},
{TOK_SETREBOOTFLAG,"SetRebootFlag",1,0,"true|false"}, {TOK_SETREBOOTFLAG,"SetRebootFlag",1,0,"true|false"},
{TOK_SETSHELLVARCONTEXT,"SetShellVarContext",1,0,"all|current"}, {TOK_SETSHELLVARCONTEXT,"SetShellVarContext",1,0,"all|current"},