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

@ -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

View file

@ -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);
}

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_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"},