From f0a60a1471efa1c6a1c4c0dfee7475c3a0068b3e Mon Sep 17 00:00:00 2001 From: TimeServ Date: Fri, 5 May 2006 05:28:56 +0000 Subject: [PATCH] don't use va() within FS_Rename, fix logging logic, fix return values with morphos call git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2239 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/sys_morphos.c | 4 ++-- engine/common/fs.c | 22 ++++++++++++++-------- engine/common/log.c | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/engine/client/sys_morphos.c b/engine/client/sys_morphos.c index 185c5ed5a..9a5c64009 100755 --- a/engine/client/sys_morphos.c +++ b/engine/client/sys_morphos.c @@ -103,10 +103,10 @@ int Sys_DebugLog(char *file, char *fmt, ...) Close(fh); - return true; + return 0; } - return false; + return 1; } int secbase; diff --git a/engine/common/fs.c b/engine/common/fs.c index 6a5356346..3a45b74fe 100644 --- a/engine/common/fs.c +++ b/engine/common/fs.c @@ -2170,32 +2170,38 @@ int FS_Rename2(char *oldf, char *newf, int oldrelativeto, int newrelativeto) } int FS_Rename(char *oldf, char *newf, int relativeto) { - char fullname[MAX_OSPATH]; + char oldfullname[MAX_OSPATH]; + char newfullname[MAX_OSPATH]; switch (relativeto) { case FS_GAME: if (*com_homedir) - snprintf(fullname, sizeof(fullname), "%s%s/", com_homedir, gamedirfile); + snprintf(oldfullname, sizeof(oldfullname), "%s%s/", com_homedir, gamedirfile); else - snprintf(fullname, sizeof(fullname), "%s%s/", com_quakedir, gamedirfile); + snprintf(oldfullname, sizeof(oldfullname), "%s%s/", com_quakedir, gamedirfile); break; case FS_SKINS: if (*com_homedir) - snprintf(fullname, sizeof(fullname), "%sqw/skins/", com_homedir); + snprintf(oldfullname, sizeof(oldfullname), "%sqw/skins/", com_homedir); else - snprintf(fullname, sizeof(fullname), "%sqw/skins/", com_quakedir); + snprintf(oldfullname, sizeof(oldfullname), "%sqw/skins/", com_quakedir); break; case FS_BASE: if (*com_homedir) - snprintf(fullname, sizeof(fullname), "%s", com_homedir); + snprintf(oldfullname, sizeof(oldfullname), "%s", com_homedir); else - snprintf(fullname, sizeof(fullname), "%s", com_quakedir); + snprintf(oldfullname, sizeof(oldfullname), "%s", com_quakedir); break; default: Sys_Error("FS_Rename case not handled\n"); } - return rename(va("%s%s", fullname, oldf), va("%s%s", fullname, newf)); + + Q_strncpy(newfullname, oldfullname, sizeof(newfullname)); + Q_strncatz(oldfullname, oldf, sizeof(oldfullname)); + Q_strncatz(newfullname, newf, sizeof(newfullname)); + + return rename(oldfullname, newfullname); } int FS_Remove(char *fname, int relativeto) { diff --git a/engine/common/log.c b/engine/common/log.c index 72da14880..446d4b1c6 100644 --- a/engine/common/log.c +++ b/engine/common/log.c @@ -199,7 +199,7 @@ void Con_Log (char *s) snprintf(oldf, sizeof(oldf)-1, "%s.%i", f, x); // check if file exists, otherwise skip - if ((fi = FS_OpenVFS(f, "rb", FS_BASE))) + if ((fi = FS_OpenVFS(oldf, "rb", FS_BASE))) VFS_CLOSE(fi); else continue; // skip nonexistant files