1
0
Fork 0
forked from fte/fteqw

------------------------------------------------------------------------

r4215 | acceptthis | 2013-02-18 06:03:26 +0000 (Mon, 18 Feb 2013) | 1 line

Make the browser plugin more robust.
------------------------------------------------------------------------


git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4212 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2013-03-12 23:01:33 +00:00
parent f7c0eff8c6
commit 85128de90a
2 changed files with 48 additions and 8 deletions

View file

@ -542,6 +542,25 @@ qboolean Update_GetHomeDirectory(char *homedir, int homedirsize)
return false;
}
void Sys_mkdir (char *path)
{
CreateDirectory (path, NULL);
}
static void Update_CreatePath (char *path)
{
char *ofs;
for (ofs = path+1 ; *ofs ; ofs++)
{
if (*ofs == '/' || *ofs == '\\')
{ // create the directory
*ofs = 0;
Sys_mkdir (path);
*ofs = '/';
}
}
}
#include "fs.h"
struct dl_download *enginedownloadactive;
void Update_Version_Updated(struct dl_download *dl)
@ -558,6 +577,7 @@ void Update_Version_Updated(struct dl_download *dl)
Update_GetHomeDirectory(pendingname, sizeof(pendingname));
Q_strncatz(pendingname, DISTRIBUTION BUILDTYPE EXETYPE".tmp", sizeof(pendingname));
fullsize = VFS_GETLEN(dl->file);
Update_CreatePath(pendingname);
pending = fopen(pendingname, "wb");
if (pending)
{
@ -578,6 +598,8 @@ void Update_Version_Updated(struct dl_download *dl)
dl->status = DL_FAILED;
}
}
else
dl->status = DL_FAILED;
}
VFS_CLOSE(dl->file);
dl->file = NULL;
@ -602,7 +624,7 @@ qboolean Plug_GetDownloadedName(char *updatedpath, int updatedpathlen)
{
MyRegDeleteKeyValue(HKEY_CURRENT_USER, "Software\\"FULLENGINENAME, "pending" BUILDTYPE EXETYPE);
Update_GetHomeDirectory(temppath, sizeof(temppath));
CreateDirectory(temppath, NULL);
Update_CreatePath(temppath);
Q_strncatz(temppath, "cur" BUILDTYPE EXETYPE".exe", sizeof(temppath));
DeleteFile(temppath);
if (MoveFile(pendingpath, temppath))
@ -611,6 +633,8 @@ qboolean Plug_GetDownloadedName(char *updatedpath, int updatedpathlen)
/*grab the binary to run from the registry*/
MyRegGetStringValue(HKEY_CURRENT_USER, "Software\\"FULLENGINENAME, BUILDTYPE EXETYPE, updatedpath, updatedpathlen);
if (*updatedpath && INVALID_FILE_ATTRIBUTES==GetFileAttributes(updatedpath)) //make sure its actually still there.
*updatedpath = 0;
if (!*updatedpath)
{
/*ooer, its not set, try and download one. updates are handled by the client itself.*/
@ -756,14 +780,15 @@ char *cleanarg(char *arg)
qboolean Plug_GetBinaryName(char *exe, int exelen,
char *basedir, int basedirlen)
{
char buffer[1024];
char cmd[64];
char value[1024];
FILE *f;
Q_snprintfz(buffer, sizeof(buffer), "%s%s", binarypath, "npfte.txt");
// char buffer[1024];
// char cmd[64];
// char value[1024];
// FILE *f;
*exe = 0;
*basedir = 0;
/*
Q_snprintfz(buffer, sizeof(buffer), "%s%s", binarypath, "npfte.txt");
f = fopen(buffer, "rt");
if (f)
@ -782,7 +807,7 @@ qboolean Plug_GetBinaryName(char *exe, int exelen,
}
fclose(f);
}
*/
if (!*exe)
return Plug_GetDownloadedName(exe, exelen);
return false;

View file

@ -2155,6 +2155,21 @@ void Update_Check(void)
}
}
static void Update_CreatePath (char *path)
{
char *ofs;
for (ofs = path+1 ; *ofs ; ofs++)
{
if (*ofs == '/')
{ // create the directory
*ofs = 0;
Sys_mkdir (path);
*ofs = '/';
}
}
}
qboolean Sys_CheckUpdated(void)
{
int ffe = COM_CheckParm("--fromfrontend");
@ -2183,7 +2198,7 @@ qboolean Sys_CheckUpdated(void)
{
MyRegDeleteKeyValue(HKEY_CURRENT_USER, "Software\\"FULLENGINENAME, "pending" BUILDTYPE EXETYPE);
Update_GetHomeDirectory(updatedpath, sizeof(updatedpath));
CreateDirectory(updatedpath, NULL);
Update_CreatePath(updatedpath);
Q_strncatz(updatedpath, "cur" BUILDTYPE EXETYPE".exe", sizeof(updatedpath));
DeleteFile(updatedpath);
if (MoveFile(pendingpath, updatedpath))