diff --git a/YSI_Core/y_utils/y_utils_files.inc b/YSI_Core/y_utils/y_utils_files.inc index acade7dc..d0bc0bc9 100644 --- a/YSI_Core/y_utils/y_utils_files.inc +++ b/YSI_Core/y_utils/y_utils_files.inc @@ -104,32 +104,32 @@ Optional plugins: * *//*------------------------------------------------------------------------**/ -#if !defined ftouch || defined y_utils_ftouch - stock ftouch(const string:filename[]) +stock YSI_ftouch__(const string:filename[]) +{ + if (fexist(filename)) + { + return 0; + } + else { - if (fexist(filename)) + new + File:f = fopen(filename, io_write); + if (f) { - return 0; + fclose(f); + return 1; } else { - new - File:f = fopen(filename, io_write); - if (f) - { - fclose(f); - return 1; - } - else - { - return -1; - } + return -1; } } +} - static stock y_utils_ftouch() - { - } +#if !defined ftouch + // Turns out there's a bug in open.mp's `ftouch`, for now. + #define ftouch( YSI_ftouch__( + #define _ALS_ftouch #endif /*-------------------------------------------------------------------------*//** diff --git a/YSI_Players/y_users/y_users_ini.inc b/YSI_Players/y_users/y_users_ini.inc index 43b9cdbc..77c9f3fa 100644 --- a/YSI_Players/y_users/y_users_ini.inc +++ b/YSI_Players/y_users/y_users_ini.inc @@ -275,7 +275,7 @@ stock Player_IsRegistered(playerid) HOOK__ OnYSIInit() { - switch (ftouch(USER_FILE_PATH "index.YSI")) + switch (YSI_ftouch__(USER_FILE_PATH "index.YSI")) { case -1: { @@ -286,14 +286,14 @@ HOOK__ OnYSIInit() if (Player_CreateNewID()) { // Don't need upgrades. - if (ftouch(USER_FILE_PATH "y_users_v2_1.YSI") == -1) + if (YSI_ftouch__(USER_FILE_PATH "y_users_v2_1.YSI") == -1) { Debug_Error("Could not touch upgrade file 1."); // Use "else" so we don't try do upgrade 2 without upgrade // 1. That would really mess up the files (that don't yet // exist, but could do). } - else if (ftouch(USER_FILE_PATH "y_users_v2_2.YSI") == -1) + else if (YSI_ftouch__(USER_FILE_PATH "y_users_v2_2.YSI") == -1) { Debug_Error("Could not touch upgrade file 2."); } @@ -1255,7 +1255,7 @@ static stock Player_CreateNewID() static stock Users_DoUpgrade0() { // Only ever do this upgrade once. - switch (ftouch(USER_FILE_PATH "y_users_v2_1.YSI")) + switch (YSI_ftouch__(USER_FILE_PATH "y_users_v2_1.YSI")) { case -1: { @@ -1371,7 +1371,7 @@ static stock Users_DoUpgrade0() static stock Users_DoUpgrade1() { // Only ever do this upgrade once. - switch (ftouch(USER_FILE_PATH "y_users_v2_2.YSI")) + switch (YSI_ftouch__(USER_FILE_PATH "y_users_v2_2.YSI")) { // case 0: Already exists. case -1: diff --git a/YSI_Players/y_users/y_users_mysql.inc b/YSI_Players/y_users/y_users_mysql.inc index ba96e6f1..82fb50e7 100644 --- a/YSI_Players/y_users/y_users_mysql.inc +++ b/YSI_Players/y_users/y_users_mysql.inc @@ -261,7 +261,7 @@ stock Player_IsRegistered(playerid) HOOK__ OnYSIInit() { - switch (ftouch(USER_FILE_PATH "index.YSI")) + switch (YSI_ftouch__(USER_FILE_PATH "index.YSI")) { case -1: { diff --git a/YSI_Storage/y_ini/y_ini_impl.inc b/YSI_Storage/y_ini/y_ini_impl.inc index 8f30d06c..9d626d8b 100644 --- a/YSI_Storage/y_ini/y_ini_impl.inc +++ b/YSI_Storage/y_ini/y_ini_impl.inc @@ -988,7 +988,7 @@ static stock bool:INI_SetTag_(INI:file, const tag[]) stock INI:INI_Open(const filename[]) { Debug_Print3("INI:INI_Open called: \"%s\"", filename); - if (ftouch(filename) == -1) + if (YSI_ftouch__(filename) == -1) { Debug_Warning("INI_Open could not find or create file %s", filename); } diff --git a/YSI_Storage/y_ini/y_ini_tests.inc b/YSI_Storage/y_ini/y_ini_tests.inc index 1a52fc88..54d9debf 100644 --- a/YSI_Storage/y_ini/y_ini_tests.inc +++ b/YSI_Storage/y_ini/y_ini_tests.inc @@ -951,25 +951,11 @@ public INI_PUB_Inl_(string:name[], string:value[]) fclose(f); } - printf("a:"); - if ((f = fopen(MakeYINITestPath("test10.ini"), io_read))) - { - while (fread(f, str)) printf(str); - fclose(f); - } - new INI:i = INI_Open(MakeYINITestPath("test10.ini")); INI_SetTag(i, "tag_with_parent"); INI_RemoveEntry(i, "value"); INI_Close(i); - printf("b:"); - if ((f = fopen(MakeYINITestPath("test10.ini"), io_read))) - { - while (fread(f, str)) printf(str); - fclose(f); - } - f = fopen(MakeYINITestPath("test10.ini"), io_read); ASSERT(!!f); if (f)