Rework build pathname functions (#422)

* Rework build_pathname* functions

* Replace old platform defines with the new ones

* Correct usage of build_pathname_r()

* Fix inconsistencies (white spaces)

* Remove useless defines
This commit is contained in:
Karol Szuster 2017-03-11 19:26:25 +01:00 committed by Vincent Herbet
parent fa3d28872e
commit 9551c70c59
13 changed files with 688 additions and 734 deletions

View File

@ -61,8 +61,8 @@ void CPluginMngr::Finalize()
int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn) int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
{ {
char file[256]; char file[PLATFORM_MAX_PATH];
FILE *fp = fopen(build_pathname_r(file, sizeof(file) - 1, "%s", filename), "rt"); FILE *fp = fopen(build_pathname_r(file, sizeof(file), "%s", filename), "rt");
if (!fp) if (!fp)
{ {
@ -276,8 +276,8 @@ CPluginMngr::CPlugin::CPlugin(int i, const char* p, const char* n, char* e, int
author = unk; author = unk;
version = unk; version = unk;
char file[256]; char file[PLATFORM_MAX_PATH];
char* path = build_pathname_r(file, sizeof(file) - 1, "%s/%s", p, n); char* path = build_pathname_r(file, sizeof(file), "%s/%s", p, n);
code = 0; code = 0;
memset(&amx, 0, sizeof(AMX)); memset(&amx, 0, sizeof(AMX));
int err = load_amxscript(&amx, &code, path, e, d); int err = load_amxscript(&amx, &code, path, e, d);
@ -688,8 +688,8 @@ void CPluginMngr::CacheAndLoadModules(const char *plugin)
void CPluginMngr::CALMFromFile(const char *file) void CPluginMngr::CALMFromFile(const char *file)
{ {
char filename[256]; char filename[PLATFORM_MAX_PATH];
FILE *fp = fopen(build_pathname_r(filename, sizeof(filename) - 1, "%s", file), "rt"); FILE *fp = fopen(build_pathname_r(filename, sizeof(filename), "%s", file), "rt");
if (!fp) if (!fp)
{ {
@ -751,7 +751,7 @@ void CPluginMngr::CALMFromFile(const char *file)
continue; continue;
} }
build_pathname_r(filename, sizeof(filename)-1, "%s/%s", get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins"), pluginName); build_pathname_r(filename, sizeof(filename), "%s/%s", get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins"), pluginName);
CacheAndLoadModules(filename); CacheAndLoadModules(filename);
} }

View File

@ -1468,9 +1468,9 @@ static cell AMX_NATIVE_CALL amx_md5_file(AMX *amx, cell *params)
{ {
int len; int len;
char *str = get_amxstring(amx, params[1], 0, len); char *str = get_amxstring(amx, params[1], 0, len);
char file[255]; char file[PLATFORM_MAX_PATH];
build_pathname_r(file, sizeof(file)-1, "%s", str); build_pathname_r(file, sizeof(file), "%s", str);
const char *hash = hashFile((const char *)file, Hash_Md5); const char *hash = hashFile((const char *)file, Hash_Md5);
if (!hash) if (!hash)
@ -1502,8 +1502,8 @@ static cell AMX_NATIVE_CALL amx_hash_file(AMX *amx, cell *params)
{ {
int len; int len;
char *str = get_amxstring(amx, params[1], 0, len); char *str = get_amxstring(amx, params[1], 0, len);
char file[255]; char file[PLATFORM_MAX_PATH];
build_pathname_r(file, sizeof(file)-1, "%s", str); build_pathname_r(file, sizeof(file), "%s", str);
HashType type = (HashType)params[2]; HashType type = (HashType)params[2];
@ -2016,13 +2016,13 @@ static cell AMX_NATIVE_CALL log_to_file(AMX *amx, cell *params) /* 1 param */
int ilen; int ilen;
char* szFile = get_amxstring(amx, params[1], 0, ilen); char* szFile = get_amxstring(amx, params[1], 0, ilen);
FILE*fp; FILE*fp;
char file[256]; char file[PLATFORM_MAX_PATH];
if (strchr(szFile, '/') || strchr(szFile, '\\')) if (strchr(szFile, '/') || strchr(szFile, '\\'))
{ {
build_pathname_r(file, sizeof(file) - 1, "%s", szFile); build_pathname_r(file, sizeof(file), "%s", szFile);
} else { } else {
build_pathname_r(file, sizeof(file) - 1, "%s/%s", g_log_dir.chars(), szFile); build_pathname_r(file, sizeof(file), "%s/%s", g_log_dir.chars(), szFile);
} }
bool first_time = true; bool first_time = true;
@ -3891,8 +3891,8 @@ static cell AMX_NATIVE_CALL get_lang(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL register_dictionary(AMX *amx, cell *params) static cell AMX_NATIVE_CALL register_dictionary(AMX *amx, cell *params)
{ {
int len; int len;
static char file[256]; static char file[PLATFORM_MAX_PATH];
int result = g_langMngr.MergeDefinitionFile(build_pathname_r(file, sizeof(file) - 1, "%s/lang/%s", get_localinfo("amxx_datadir", "addons/amxmodx/data"), get_amxstring(amx, params[1], 1, len))); int result = g_langMngr.MergeDefinitionFile(build_pathname_r(file, sizeof(file), "%s/lang/%s", get_localinfo("amxx_datadir", "addons/amxmodx/data"), get_amxstring(amx, params[1], 1, len)));
return result; return result;
} }

View File

@ -10,7 +10,7 @@
#ifndef AMXMODX_H #ifndef AMXMODX_H
#define AMXMODX_H #define AMXMODX_H
#if defined(__linux__) || defined(__APPLE__) #if defined PLATFORM_POSIX
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include "sclinux.h" #include "sclinux.h"
@ -75,7 +75,7 @@ extern AMX_NATIVE_INFO g_TextParserNatives[];
extern AMX_NATIVE_INFO g_CvarNatives[]; extern AMX_NATIVE_INFO g_CvarNatives[];
extern AMX_NATIVE_INFO g_GameConfigNatives[]; extern AMX_NATIVE_INFO g_GameConfigNatives[];
#if defined(_WIN32) #if defined PLATFORM_WINDOWS
#define DLLOAD(path) (DLHANDLE)LoadLibrary(path) #define DLLOAD(path) (DLHANDLE)LoadLibrary(path)
#define DLPROC(m, func) GetProcAddress(m, func) #define DLPROC(m, func) GetProcAddress(m, func)
#define DLFREE(m) FreeLibrary(m) #define DLFREE(m) FreeLibrary(m)
@ -96,21 +96,13 @@ extern AMX_NATIVE_INFO g_GameConfigNatives[];
#endif #endif
#endif #endif
#if defined(_WIN32) #if defined PLATFORM_WINDOWS
typedef HINSTANCE DLHANDLE; typedef HINSTANCE DLHANDLE;
#else #else
typedef void* DLHANDLE; typedef void* DLHANDLE;
#define INFINITE 0xFFFFFFFF #define INFINITE 0xFFFFFFFF
#endif #endif
#if defined(_WIN32)
#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

@ -75,14 +75,14 @@ void CLog::CreateNewFile()
time(&td); time(&td);
tm *curTime = localtime(&td); tm *curTime = localtime(&td);
char file[256]; char file[PLATFORM_MAX_PATH];
char name[256]; char name[256];
int i = 0; int i = 0;
while (true) while (true)
{ {
ke::SafeSprintf(name, sizeof(name), "%s/L%02d%02d%03d.log", g_log_dir.chars(), curTime->tm_mon + 1, curTime->tm_mday, i); ke::SafeSprintf(name, sizeof(name), "%s/L%02d%02d%03d.log", g_log_dir.chars(), curTime->tm_mon + 1, curTime->tm_mday, i);
build_pathname_r(file, sizeof(file)-1, "%s", name); build_pathname_r(file, sizeof(file), "%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
if (!pTmpFile) if (!pTmpFile)
@ -108,8 +108,8 @@ void CLog::CreateNewFile()
void CLog::UseFile(const ke::AString &fileName) void CLog::UseFile(const ke::AString &fileName)
{ {
static char file[256]; static char file[PLATFORM_MAX_PATH];
m_LogFile = build_pathname_r(file, sizeof(file) - 1, "%s/%s", g_log_dir.chars(), fileName.chars()); m_LogFile = build_pathname_r(file, sizeof(file), "%s/%s", g_log_dir.chars(), fileName.chars());
} }
void CLog::SetLogType(const char* localInfo) void CLog::SetLogType(const char* localInfo)
@ -128,11 +128,11 @@ void CLog::SetLogType(const char* localInfo)
void CLog::MapChange() void CLog::MapChange()
{ {
// create dir if not existing // create dir if not existing
char file[256]; char file[PLATFORM_MAX_PATH];
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
mkdir(build_pathname_r(file, sizeof(file)-1, "%s", g_log_dir.chars()), 0700); mkdir(build_pathname_r(file, sizeof(file), "%s", g_log_dir.chars()), 0700);
#else #else
mkdir(build_pathname_r(file, sizeof(file) - 1, "%s", g_log_dir.chars())); mkdir(build_pathname_r(file, sizeof(file), "%s", g_log_dir.chars()));
#endif #endif
SetLogType("amxx_logging"); SetLogType("amxx_logging");
@ -152,7 +152,7 @@ void CLog::MapChange()
void CLog::Log(const char *fmt, ...) void CLog::Log(const char *fmt, ...)
{ {
static char file[256]; static char file[PLATFORM_MAX_PATH];
if (m_LogType == 1 || m_LogType == 2) if (m_LogType == 1 || m_LogType == 2)
{ {
@ -189,7 +189,7 @@ void CLog::Log(const char *fmt, ...)
} }
} }
} else { } else {
build_pathname_r(file, sizeof(file) - 1, "%s/L%04d%02d%02d.log", g_log_dir.chars(), (curTime->tm_year + 1900), curTime->tm_mon + 1, curTime->tm_mday); build_pathname_r(file, sizeof(file), "%s/L%04d%02d%02d.log", g_log_dir.chars(), (curTime->tm_year + 1900), curTime->tm_mon + 1, curTime->tm_mday);
pF = fopen(file, "a+"); pF = fopen(file, "a+");
} }
@ -218,7 +218,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[PLATFORM_MAX_PATH];
static char name[256]; static char name[256];
if (m_FoundError) if (m_FoundError)
@ -244,7 +244,7 @@ void CLog::LogError(const char *fmt, ...)
FILE *pF = NULL; FILE *pF = NULL;
ke::SafeSprintf(name, sizeof(name), "%s/error_%04d%02d%02d.log", g_log_dir.chars(), curTime->tm_year + 1900, curTime->tm_mon + 1, curTime->tm_mday); ke::SafeSprintf(name, sizeof(name), "%s/error_%04d%02d%02d.log", g_log_dir.chars(), curTime->tm_year + 1900, curTime->tm_mon + 1, curTime->tm_mday);
build_pathname_r(file, sizeof(file)-1, "%s", name); build_pathname_r(file, sizeof(file), "%s", name);
pF = fopen(file, "a+"); pF = fopen(file, "a+");
if (pF) if (pF)
@ -266,4 +266,3 @@ void CLog::LogError(const char *fmt, ...)
// print on server console // print on server console
print_srvconsole("L %s: %s\n", date, msg); print_srvconsole("L %s: %s\n", date, msg);
} }

View File

@ -49,8 +49,8 @@ int LookupFile(AMX_DBG *amxdbg, ucell address)
bool BinLog::Open() bool BinLog::Open()
{ {
const char *data = get_localinfo("amxmodx_datadir", "addons/amxmodx/data"); const char *data = get_localinfo("amxmodx_datadir", "addons/amxmodx/data");
char path[255]; char path[PLATFORM_MAX_PATH];
build_pathname_r(path, sizeof(path)-1, "%s/binlogs", data); build_pathname_r(path, sizeof(path), "%s/binlogs", data);
if (!DirExists(path)) if (!DirExists(path))
{ {
@ -63,8 +63,8 @@ bool BinLog::Open()
return false; return false;
} }
char file[255]; char file[PLATFORM_MAX_PATH];
build_pathname_r(file, sizeof(file)-1, "%s/binlogs/lastlog", data); build_pathname_r(file, sizeof(file), "%s/binlogs/lastlog", data);
unsigned int lastcntr = 0; unsigned int lastcntr = 0;
FILE *lastlog = fopen(file, "rb"); FILE *lastlog = fopen(file, "rb");
@ -81,7 +81,7 @@ bool BinLog::Open()
fwrite(&lastcntr, sizeof(int), 1, lastlog); fwrite(&lastcntr, sizeof(int), 1, lastlog);
fclose(lastlog); fclose(lastlog);
} }
build_pathname_r(file, sizeof(file)-1, "%s/binlogs/binlog%04d.blg", data, lastcntr); build_pathname_r(file, sizeof(file), "%s/binlogs/binlog%04d.blg", data, lastcntr);
m_logfile = file; m_logfile = file;
/** /**

View File

@ -1015,8 +1015,8 @@ static cell AMX_NATIVE_CALL rename_file(AMX *amx, cell *params)
if (params[0] / sizeof(cell) >= 3 && params[3] > 0) if (params[0] / sizeof(cell) >= 3 && params[3] > 0)
{ {
build_pathname_r(file_old_r, sizeof(file_old_r) - 1, "%s", file_old); build_pathname_r(file_old_r, sizeof(file_old_r), "%s", file_old);
build_pathname_r(file_new_r, sizeof(file_new_r) - 1, "%s", file_new); build_pathname_r(file_new_r, sizeof(file_new_r), "%s", file_new);
} }
else else
{ {

View File

@ -187,9 +187,9 @@ void ParseAndOrAdd(CStack<ke::AString *> & files, const char *name)
void BuildPluginFileList(const char *initialdir, CStack<ke::AString *> & files) void BuildPluginFileList(const char *initialdir, CStack<ke::AString *> & files)
{ {
char path[255]; char path[PLATFORM_MAX_PATH];
#if defined WIN32 #if defined WIN32
build_pathname_r(path, sizeof(path)-1, "%s/*.ini", initialdir); build_pathname_r(path, sizeof(path), "%s/*.ini", initialdir);
_finddata_t fd; _finddata_t fd;
intptr_t handle = _findfirst(path, &fd); intptr_t handle = _findfirst(path, &fd);
@ -205,7 +205,7 @@ void BuildPluginFileList(const char *initialdir, CStack<ke::AString *> & files)
_findclose(handle); _findclose(handle);
#elif defined(__linux__) || defined(__APPLE__) #elif defined(__linux__) || defined(__APPLE__)
build_pathname_r(path, sizeof(path)-1, "%s/", initialdir); build_pathname_r(path, sizeof(path), "%s/", initialdir);
struct dirent *ep; struct dirent *ep;
DIR *dp; DIR *dp;
@ -463,8 +463,8 @@ int C_Spawn(edict_t *pent)
CVAR_SET_STRING(init_amxmodx_modules.name, buffer); CVAR_SET_STRING(init_amxmodx_modules.name, buffer);
// ###### Load Vault // ###### Load Vault
char file[255]; char file[PLATFORM_MAX_PATH];
g_vault.setSource(build_pathname_r(file, sizeof(file) - 1, "%s", get_localinfo("amxx_vault", "addons/amxmodx/configs/vault.ini"))); g_vault.setSource(build_pathname_r(file, sizeof(file), "%s", get_localinfo("amxx_vault", "addons/amxmodx/configs/vault.ini")));
g_vault.loadVault(); g_vault.loadVault();
// ###### Init time and freeze tasks // ###### Init time and freeze tasks

View File

@ -31,6 +31,7 @@
#include "trie_natives.h" #include "trie_natives.h"
#include "CDataPack.h" #include "CDataPack.h"
#include "CGameConfigs.h" #include "CGameConfigs.h"
#include <amtl/os/am-path.h>
CList<CModule, const char*> g_modules; CList<CModule, const char*> g_modules;
CList<CScript, AMX*> g_loadedscripts; CList<CScript, AMX*> g_loadedscripts;
@ -673,75 +674,39 @@ void get_modname(char* buffer)
char *build_pathname(const char *fmt, ...) char *build_pathname(const char *fmt, ...)
{ {
static char string[256]; static char string[PLATFORM_MAX_PATH];
int b; auto len = ke::path::Format(string, sizeof(string), "%s/", g_mod_name.chars());
int a = b = ke::SafeSprintf(string, sizeof(string), "%s%c", g_mod_name.chars(), PATH_SEP_CHAR);
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
a += vsnprintf (&string[a], 255 - a, fmt, argptr); ke::path::FormatVa(&string[len], sizeof(string) - len, fmt, argptr);
string[a] = 0;
va_end(argptr); va_end(argptr);
char* path = &string[b];
while (*path)
{
if (*path == ALT_SEP_CHAR)
{
*path = PATH_SEP_CHAR;
}
++path;
}
return string; return string;
} }
char *build_pathname_r(char *buffer, size_t maxlen, const char *fmt, ...) char *build_pathname_r(char *buffer, size_t maxlen, const char *fmt, ...)
{ {
ke::SafeSprintf(buffer, maxlen, "%s%c", g_mod_name.chars(), PATH_SEP_CHAR); auto len = ke::path::Format(buffer, maxlen, "%s/", g_mod_name.chars());
size_t len = strlen(buffer);
char *ptr = buffer + len;
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf (ptr, maxlen-len, fmt, argptr); ke::path::FormatVa(&buffer[len], maxlen - len, fmt, argptr);
va_end (argptr); va_end (argptr);
while (*ptr)
{
if (*ptr == ALT_SEP_CHAR)
{
*ptr = PATH_SEP_CHAR;
}
++ptr;
}
return buffer; return buffer;
} }
// build pathname based on addons dir // build pathname based on addons dir
char *build_pathname_addons(const char *fmt, ...) char *build_pathname_addons(const char *fmt, ...)
{ {
static char string[256]; static char string[PLATFORM_MAX_PATH];
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf (string, 255, fmt, argptr); ke::path::FormatVa(string, sizeof(string), fmt, argptr);
va_end(argptr); va_end(argptr);
char* path = string;
while (*path)
{
if (*path == ALT_SEP_CHAR)
{
*path = PATH_SEP_CHAR;
}
++path;
}
return string; return string;
} }
@ -762,7 +727,7 @@ bool ConvertModuleName(const char *pathString, char *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 != PATH_SEP_CHAR) while (ptr >= tmpname && *ptr != PLATFORM_SEP_CHAR)
ptr--; ptr--;
if (ptr >= tmpname) if (ptr >= tmpname)
{ {
@ -822,7 +787,7 @@ bool ConvertModuleName(const char *pathString, char *path)
*ptr = '\0'; *ptr = '\0';
} }
size_t length = ke::SafeSprintf(path, PLATFORM_MAX_PATH, "%s%c%s_amxx", orig_path, PATH_SEP_CHAR, tmpname); auto length = ke::path::Format(path, PLATFORM_MAX_PATH, "%s/%s_amxx", orig_path, tmpname);
#if defined PLATFORM_LINUX #if defined PLATFORM_LINUX
# if defined AMD64 || PAWN_CELL_SIZE == 64 # if defined AMD64 || PAWN_CELL_SIZE == 64
@ -843,7 +808,7 @@ bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify, bool no
build_pathname_r( build_pathname_r(
pathString, pathString,
sizeof(pathString)-1, sizeof(pathString),
"%s/%s", "%s/%s",
get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"), get_localinfo("amxx_modulesdir", "addons/amxmodx/modules"),
shortname); shortname);

View File

@ -307,7 +307,7 @@ int ReadConfig(void)
{ {
char FileName[512]; char FileName[512];
MF_BuildPathnameR(FileName,sizeof(FileName)-1,"%s",get_localinfo("amxx_configsdir","addons/amxmodx/configs")); MF_BuildPathnameR(FileName,sizeof(FileName),"%s",get_localinfo("amxx_configsdir","addons/amxmodx/configs"));
strncat(FileName,"/hamdata.ini",sizeof(FileName)-1); strncat(FileName,"/hamdata.ini",sizeof(FileName)-1);

View File

@ -46,7 +46,7 @@ static cell nvault_open(AMX *amx, cell *params)
int len, id=-1; int len, id=-1;
char *name = MF_GetAmxString(amx, params[1], 0, &len); char *name = MF_GetAmxString(amx, params[1], 0, &len);
char path[255], file[255]; char path[255], file[255];
MF_BuildPathnameR(path, sizeof(path)-1, "%s/vault", MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data")); MF_BuildPathnameR(path, sizeof(path), "%s/vault", MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"));
sprintf(file, "%s/%s.vault", path, name); sprintf(file, "%s/%s.vault", path, name);
for (size_t i=0; i<g_Vaults.length(); i++) for (size_t i=0; i<g_Vaults.length(); i++)
{ {

View File

@ -59,13 +59,13 @@ static cell AMX_NATIVE_CALL SQL_MakeDbTuple(AMX *amx, cell *params)
char path[255]; char path[255];
FILE *fp; FILE *fp;
MF_BuildPathnameR(path, sizeof(path)-1, "%s", db); MF_BuildPathnameR(path, sizeof(path), "%s", db);
if ((fp=fopen(path, "rb"))) if ((fp=fopen(path, "rb")))
{ {
fclose(fp); fclose(fp);
sql->db = strdup(path); sql->db = strdup(path);
} else { } else {
MF_BuildPathnameR(path, sizeof(path)-1, "%s/sqlite3/%s.sq3", MF_BuildPathnameR(path, sizeof(path), "%s/sqlite3/%s.sq3",
MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"), MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"),
db); db);
sql->db = strdup(path); sql->db = strdup(path);
@ -630,4 +630,3 @@ AMX_NATIVE_INFO g_BaseSqlNatives[] =
{NULL, NULL}, {NULL, NULL},
}; };

View File

@ -69,7 +69,7 @@ void OnAmxxAttach()
MF_OverrideNatives(g_OldCompatNatives, MODULE_NAME); MF_OverrideNatives(g_OldCompatNatives, MODULE_NAME);
char path[255]; char path[255];
MF_BuildPathnameR(path, sizeof(path)-1, "%s/sqlite3", MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data")); MF_BuildPathnameR(path, sizeof(path), "%s/sqlite3", MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"));
if (!DirExists(path)) if (!DirExists(path))
{ {
mkdir(path mkdir(path
@ -96,4 +96,3 @@ void OnPluginsUnloaded()
extern "C" void __cxa_pure_virtual(void) extern "C" void __cxa_pure_virtual(void)
{ {
} }

View File

@ -73,14 +73,14 @@ static cell AMX_NATIVE_CALL dbi_connect(AMX *amx, cell *params)
int err; int err;
char error[512]; char error[512];
/** if there is an older database, read there instead of the new path */ /** if there is an older database, read there instead of the new path */
MF_BuildPathnameR(path, sizeof(path)-1, "%s", info.database); MF_BuildPathnameR(path, sizeof(path), "%s", info.database);
FILE *fp = fopen(path, "rb"); FILE *fp = fopen(path, "rb");
if (fp) if (fp)
{ {
fclose(fp); fclose(fp);
info.database = path; info.database = path;
} else { } else {
MF_BuildPathnameR(path, sizeof(path)-1, "%s/sqlite3/%s.sq3", MF_BuildPathnameR(path, sizeof(path), "%s/sqlite3/%s.sq3",
MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"), MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"),
info.database); info.database);
info.database = path; info.database = path;