Permalink
Browse files

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

  • Loading branch information...
jacob1 committed Mar 14, 2018
1 parent 01741b0 commit 96de9bbc365593fca849e93408c1dd58e59d1358
Showing with 12 additions and 4 deletions.
  1. +12 −4 src/Update.cpp
@@ -41,7 +41,7 @@ int update_start(char *data, unsigned int len)
p = temp + strlen(temp) - 4;
if (_stricmp(p, ".exe"))
p += 4;
strcpy(p, "_update.exe");
strcpy(p, "_upd.exe");
if (!MoveFile(self, temp))
goto fail;
@@ -105,7 +105,7 @@ int update_finish(void)
{
#ifdef WIN
char *temp, *self = Platform::ExecutableName(), *p;
int timeout = 60, err;
int timeout = 5, err;
#ifdef DEBUG
printf("Update: Current EXE name: %s\n", self);
@@ -116,7 +116,7 @@ int update_finish(void)
p = temp + strlen(temp) - 4;
if (_stricmp(p, ".exe"))
p += 4;
strcpy(p, "_update.exe");
strcpy(p, "_upd.exe");
#ifdef DEBUG
printf("Update: Temp EXE name: %s\n", temp);
@@ -128,9 +128,17 @@ int update_finish(void)
if (err == ERROR_FILE_NOT_FOUND)
{
#ifdef DEBUG
printf("Update: Temp file deleted\n");
printf("Update: Temp file deleted\n");
#endif
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;
}
Sleep(500);

0 comments on commit 96de9bb

Please sign in to comment.