don't use _update in update filename because of windows "feature"

This commit is contained in:
jacob1 2018-03-13 22:13:15 -04:00
parent 01741b05ce
commit 96de9bbc36

View File

@ -41,7 +41,7 @@ int update_start(char *data, unsigned int len)
p = temp + strlen(temp) - 4; p = temp + strlen(temp) - 4;
if (_stricmp(p, ".exe")) if (_stricmp(p, ".exe"))
p += 4; p += 4;
strcpy(p, "_update.exe"); strcpy(p, "_upd.exe");
if (!MoveFile(self, temp)) if (!MoveFile(self, temp))
goto fail; goto fail;
@ -105,7 +105,7 @@ int update_finish(void)
{ {
#ifdef WIN #ifdef WIN
char *temp, *self = Platform::ExecutableName(), *p; char *temp, *self = Platform::ExecutableName(), *p;
int timeout = 60, err; int timeout = 5, err;
#ifdef DEBUG #ifdef DEBUG
printf("Update: Current EXE name: %s\n", self); printf("Update: Current EXE name: %s\n", self);
@ -116,7 +116,7 @@ int update_finish(void)
p = temp + strlen(temp) - 4; p = temp + strlen(temp) - 4;
if (_stricmp(p, ".exe")) if (_stricmp(p, ".exe"))
p += 4; p += 4;
strcpy(p, "_update.exe"); strcpy(p, "_upd.exe");
#ifdef DEBUG #ifdef DEBUG
printf("Update: Temp EXE name: %s\n", temp); printf("Update: Temp EXE name: %s\n", temp);
@ -131,6 +131,14 @@ int update_finish(void)
printf("Update: Temp file deleted\n"); printf("Update: Temp file deleted\n");
#endif #endif
free(temp); free(temp);
// Old versions of powder toy name their update files with _update.exe, delete that upgrade file here
temp = (char*)malloc(strlen(self)+12);
strcpy(temp, self);
p = temp + strlen(temp) - 4;
if (_stricmp(p, ".exe"))
p += 4;
strcpy(p, "_update.exe");
DeleteFile(temp);
return 0; return 0;
} }
Sleep(500); Sleep(500);