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:
committed by
Vincent Herbet
parent
fa3d28872e
commit
9551c70c59
@ -59,13 +59,13 @@ static cell AMX_NATIVE_CALL SQL_MakeDbTuple(AMX *amx, cell *params)
|
||||
char path[255];
|
||||
FILE *fp;
|
||||
|
||||
MF_BuildPathnameR(path, sizeof(path)-1, "%s", db);
|
||||
MF_BuildPathnameR(path, sizeof(path), "%s", db);
|
||||
if ((fp=fopen(path, "rb")))
|
||||
{
|
||||
fclose(fp);
|
||||
sql->db = strdup(path);
|
||||
} 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"),
|
||||
db);
|
||||
sql->db = strdup(path);
|
||||
@ -601,7 +601,7 @@ static cell AMX_NATIVE_CALL SQL_SetCharset(AMX *amx, cell *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO g_BaseSqlNatives[] =
|
||||
AMX_NATIVE_INFO g_BaseSqlNatives[] =
|
||||
{
|
||||
{"SQL_MakeDbTuple", SQL_MakeDbTuple},
|
||||
{"SQL_FreeHandle", SQL_FreeHandle},
|
||||
@ -630,4 +630,3 @@ AMX_NATIVE_INFO g_BaseSqlNatives[] =
|
||||
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
static int g_ident = 0;
|
||||
|
||||
SqlFunctions g_SqliteFuncs =
|
||||
SqlFunctions g_SqliteFuncs =
|
||||
{
|
||||
&g_Sqlite,
|
||||
SetMysqlAffinity,
|
||||
@ -69,7 +69,7 @@ void OnAmxxAttach()
|
||||
MF_OverrideNatives(g_OldCompatNatives, MODULE_NAME);
|
||||
|
||||
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))
|
||||
{
|
||||
mkdir(path
|
||||
@ -96,4 +96,3 @@ void OnPluginsUnloaded()
|
||||
extern "C" void __cxa_pure_virtual(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -73,14 +73,14 @@ static cell AMX_NATIVE_CALL dbi_connect(AMX *amx, cell *params)
|
||||
int err;
|
||||
char error[512];
|
||||
/** 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");
|
||||
if (fp)
|
||||
{
|
||||
fclose(fp);
|
||||
info.database = path;
|
||||
} 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"),
|
||||
info.database);
|
||||
info.database = path;
|
||||
@ -439,14 +439,14 @@ static cell AMX_NATIVE_CALL dbi_field_name(AMX *amx, cell *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO g_OldCompatNatives[] =
|
||||
AMX_NATIVE_INFO g_OldCompatNatives[] =
|
||||
{
|
||||
{ "dbi_connect", dbi_connect },
|
||||
{ "dbi_query", dbi_query },
|
||||
{ "dbi_query2", dbi_query2 },
|
||||
{ "dbi_field", dbi_field },
|
||||
{ "dbi_nextrow", dbi_nextrow },
|
||||
{ "dbi_close", dbi_close },
|
||||
{ "dbi_field", dbi_field },
|
||||
{ "dbi_nextrow", dbi_nextrow },
|
||||
{ "dbi_close", dbi_close },
|
||||
{ "dbi_error", dbi_error },
|
||||
{ "dbi_type", dbi_type },
|
||||
{ "dbi_free_result", dbi_free_result },
|
||||
|
Reference in New Issue
Block a user