Fixed this up or something strange like that...

This commit is contained in:
Scott Ehlert 2007-05-04 01:11:01 +00:00
parent 3b737ab87b
commit dc4c9f0258
3 changed files with 29 additions and 40 deletions

View File

@ -115,6 +115,14 @@ extern AMX_NATIVE_INFO g_DataStructNatives[];
#define INFINITE 0xFFFFFFFF #define INFINITE 0xFFFFFFFF
#endif #endif
#ifndef __linux__
#define PATH_SEP_CHAR '\\'
#define ALT_SEP_CHAR '/'
#else
#define PATH_SEP_CHAR '/'
#define ALT_SEP_CHAR '\\'
#endif
#ifndef GETPLAYERAUTHID #ifndef GETPLAYERAUTHID
#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId) #define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId)
#endif #endif

View File

@ -102,7 +102,7 @@ void CLog::CreateNewFile()
while (true) while (true)
{ {
snprintf(name, sizeof(name), "%s/L%02d%02d%03d.log", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday, i); snprintf(name, sizeof(name), "%s%cL%02d%02d%03d.log", g_log_dir.c_str(), PATH_SEP_CHAR, curTime->tm_mon + 1, curTime->tm_mday, i);
build_pathname_r(file, sizeof(file)-1, "%s", name); build_pathname_r(file, sizeof(file)-1, "%s", name);
FILE *pTmpFile = fopen(file, "r"); // open for reading to check whether the file exists FILE *pTmpFile = fopen(file, "r"); // open for reading to check whether the file exists
@ -234,6 +234,7 @@ void CLog::Log(const char *fmt, ...)
void CLog::LogError(const char *fmt, ...) void CLog::LogError(const char *fmt, ...)
{ {
static char file[256]; static char file[256];
static char name[256];
if (m_FoundError) if (m_FoundError)
{ {
@ -257,7 +258,8 @@ void CLog::LogError(const char *fmt, ...)
va_end(arglst); va_end(arglst);
FILE *pF = NULL; FILE *pF = NULL;
build_pathname_r(file, sizeof(file)-1, "%s/error_%04d%02d%02d.log", g_log_dir.c_str(), (curTime->tm_year + 1900), curTime->tm_mon + 1, curTime->tm_mday); snprintf(name, sizeof(name), "%s%cerror_%04d%02d%02d.log", g_log_dir.c_str(), PATH_SEP_CHAR, curTime->tm_year + 1900, curTime->tm_mon + 1, curTime->tm_mday);
build_pathname_r(file, sizeof(file)-1, "%s", name);
pF = fopen(file, "a+"); pF = fopen(file, "a+");
if (pF) if (pF)
@ -265,7 +267,7 @@ void CLog::LogError(const char *fmt, ...)
if (!m_LoggedErrMap) if (!m_LoggedErrMap)
{ {
fprintf(pF, "L %s: Start of error session.\n", date); fprintf(pF, "L %s: Start of error session.\n", date);
fprintf(pF, "L %s: Info (map \"%s\") (logfile \"error_%02d%02d%02d.log\")\n", date, STRING(gpGlobals->mapname), curTime->tm_mon + 1, curTime->tm_mday, curTime->tm_year - 100); fprintf(pF, "L %s: Info (map \"%s\") (file \"%s\")\n", date, STRING(gpGlobals->mapname), name);
m_LoggedErrMap = true; m_LoggedErrMap = true;
} }
fprintf(pF, "L %s: %s\n", date, msg); fprintf(pF, "L %s: %s\n", date, msg);

View File

@ -722,13 +722,7 @@ char* build_pathname(char *fmt, ...)
{ {
static char string[256]; static char string[256];
int b; int b;
int a = b = snprintf(string, 255, int a = b = snprintf(string, 255, "%s%c", g_mod_name.c_str(), PATH_SEP_CHAR);
#ifndef __linux__
"%s\\",
#else
"%s/",
#endif
g_mod_name.c_str());
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
@ -740,11 +734,10 @@ char* build_pathname(char *fmt, ...)
while (*path) while (*path)
{ {
#ifndef __linux__ if (*path == ALT_SEP_CHAR)
if (*path == '/') *path = '\\'; {
#else *path = PATH_SEP_CHAR;
if (*path == '\\') *path = '/'; }
#endif
++path; ++path;
} }
@ -753,13 +746,7 @@ char* build_pathname(char *fmt, ...)
char *build_pathname_r(char *buffer, size_t maxlen, char *fmt, ...) char *build_pathname_r(char *buffer, size_t maxlen, char *fmt, ...)
{ {
snprintf(buffer, maxlen, snprintf(buffer, maxlen, "%s%c", g_mod_name.c_str(), PATH_SEP_CHAR);
#ifdef __linux__
"%s/",
#else
"%s\\",
#endif
g_mod_name.c_str());
size_t len = strlen(buffer); size_t len = strlen(buffer);
char *ptr = buffer + len; char *ptr = buffer + len;
@ -771,11 +758,10 @@ char *build_pathname_r(char *buffer, size_t maxlen, char *fmt, ...)
while (*ptr) while (*ptr)
{ {
#ifndef __linux__ if (*ptr == ALT_SEP_CHAR)
if (*ptr == '/') *ptr = '\\'; {
#else *ptr = PATH_SEP_CHAR;
if (*ptr == '\\') *ptr = '/'; }
#endif
++ptr; ++ptr;
} }
@ -796,23 +782,16 @@ char* build_pathname_addons(char *fmt, ...)
while (*path) while (*path)
{ {
#ifndef __linux__ if (*path == ALT_SEP_CHAR)
if (*path == '/') *path = '\\'; {
#else *path = PATH_SEP_CHAR;
if (*path == '\\') *path = '/'; }
#endif
++path; ++path;
} }
return string; return string;
} }
#if defined WIN32
#define SEPCHAR '\\'
#elif defined __linux__
#define SEPCHAR '/'
#endif
bool ConvertModuleName(const char *pathString, String &path) bool ConvertModuleName(const char *pathString, String &path)
{ {
String local; String local;
@ -830,7 +809,7 @@ bool ConvertModuleName(const char *pathString, String &path)
/* run to filename instead of dir */ /* run to filename instead of dir */
char *ptr = tmpname; char *ptr = tmpname;
ptr = tmpname + len - 1; ptr = tmpname + len - 1;
while (ptr >= tmpname && *ptr != SEPCHAR) while (ptr >= tmpname && *ptr != PATH_SEP_CHAR)
ptr--; ptr--;
if (ptr >= tmpname) if (ptr >= tmpname)
{ {
@ -891,7 +870,7 @@ bool ConvertModuleName(const char *pathString, String &path)
} }
path.assign(orig_path); path.assign(orig_path);
path.append(SEPCHAR); path.append(PATH_SEP_CHAR);
path.append(tmpname); path.append(tmpname);
path.append("_amxx"); path.append("_amxx");
#if defined __linux__ #if defined __linux__