From f66ac0f4845c86ddbd02bffeff83301e99290991 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Tue, 28 Feb 2023 19:11:16 +0300 Subject: [PATCH] Use compat_fopen --- src/game/config.cc | 4 ++-- src/game/gsound.cc | 6 +++--- src/int/audiof.cc | 2 +- src/plib/db/db.cc | 12 ++++++------ src/plib/gnw/debug.cc | 2 +- src/plib/gnw/input.cc | 5 +++-- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/game/config.cc b/src/game/config.cc index 98dfe6e..98683cc 100644 --- a/src/game/config.cc +++ b/src/game/config.cc @@ -263,7 +263,7 @@ bool config_load(Config* config, const char* filePath, bool isDb) db_fclose(stream); } } else { - FILE* stream = fopen(filePath, "rt"); + FILE* stream = compat_fopen(filePath, "rt"); if (stream != NULL) { while (fgets(string, sizeof(string), stream) != NULL) { config_parse_line(config, string); @@ -309,7 +309,7 @@ bool config_save(Config* config, const char* filePath, bool isDb) db_fclose(stream); } else { - FILE* stream = fopen(filePath, "wt"); + FILE* stream = compat_fopen(filePath, "wt"); if (stream == NULL) { return false; } diff --git a/src/game/gsound.cc b/src/game/gsound.cc index 2d82114..3c9a1fb 100644 --- a/src/game/gsound.cc +++ b/src/game/gsound.cc @@ -1811,7 +1811,7 @@ static int gsound_background_find_with_copy(char* dest, const char* src) char inPath[COMPAT_MAX_PATH]; snprintf(inPath, sizeof(inPath), "%s%s%s", sound_music_path2, src, ".ACM"); - FILE* inStream = fopen(inPath, "rb"); + FILE* inStream = compat_fopen(inPath, "rb"); if (inStream == NULL) { if (gsound_debug) { debug_printf("Unable to find music file %s to copy down.\n", src); @@ -1820,7 +1820,7 @@ static int gsound_background_find_with_copy(char* dest, const char* src) return -1; } - FILE* outStream = fopen(outPath, "wb"); + FILE* outStream = compat_fopen(outPath, "wb"); if (outStream == NULL) { if (gsound_debug) { debug_printf("Unable to open music file %s for copying to.", src); @@ -2140,7 +2140,7 @@ static Sound* gsound_get_sound_ready_for_effect() // 0x449E08 static bool gsound_file_exists_f(const char* fname) { - FILE* f = fopen(fname, "rb"); + FILE* f = compat_fopen(fname, "rb"); if (f == NULL) { return false; } diff --git a/src/int/audiof.cc b/src/int/audiof.cc index 5d32bef..4d825ec 100644 --- a/src/int/audiof.cc +++ b/src/int/audiof.cc @@ -90,7 +90,7 @@ int audiofOpen(const char* fname, int flags) *pm++ = 'b'; } - FILE* stream = fopen(path, mode); + FILE* stream = compat_fopen(path, mode); if (stream == NULL) { return -1; } diff --git a/src/plib/db/db.cc b/src/plib/db/db.cc index 327bba1..a1b8519 100644 --- a/src/plib/db/db.cc +++ b/src/plib/db/db.cc @@ -302,7 +302,7 @@ int db_dir_entry(const char* name, dir_entry* de) } if (v3) { - stream = fopen(path, "rb"); + stream = compat_fopen(path, "rb"); } if (stream != NULL) { @@ -387,7 +387,7 @@ int db_read_to_buf(const char* filename, unsigned char* buf) } if (v3) { - stream = fopen(path, "rb"); + stream = compat_fopen(path, "rb"); } if (stream != NULL) { @@ -602,7 +602,7 @@ DB_FILE* db_fopen(const char* filename, const char* mode) } if (v2) { - stream = fopen(path, mode); + stream = compat_fopen(path, mode); } if (stream != NULL) { @@ -1708,7 +1708,7 @@ int db_get_file_list(const char* filespec, char*** filelist, char*** desclist, i if (db_findfirst(path, &find_data) == 0) { do { if (temp != NULL) { - FILE* stream = fopen(fileFindGetName(&find_data), "rb"); + FILE* stream = compat_fopen(fileFindGetName(&find_data), "rb"); if (stream != NULL) { if (fgets(temp, desclen, stream) != NULL) { temp[strlen(temp - 1)] = '\0'; @@ -1940,7 +1940,7 @@ static int db_init_database(DB_DATABASE* database, const char* datafile, const c return -1; } - database->stream = fopen(database->datafile, "rb"); + database->stream = compat_fopen(database->datafile, "rb"); if (database->stream == NULL) { internal_free(database->datafile); database->datafile = NULL; @@ -2193,7 +2193,7 @@ static int db_fill_hash_table(DB_DATABASE* database, const char* path) #if defined(_WIN32) snprintf(pattern, sizeof(pattern), "%s%s", path, "*.*"); -#else +#else snprintf(pattern, sizeof(pattern), "%s%s", path, "*"); #endif compat_windows_path_to_native(pattern); diff --git a/src/plib/gnw/debug.cc b/src/plib/gnw/debug.cc index d3aadc3..ea73b33 100644 --- a/src/plib/gnw/debug.cc +++ b/src/plib/gnw/debug.cc @@ -60,7 +60,7 @@ void debug_register_log(const char* fileName, const char* mode) fclose(fd); } - fd = fopen(fileName, mode); + fd = compat_fopen(fileName, mode); debug_func = debug_log; } } diff --git a/src/plib/gnw/input.cc b/src/plib/gnw/input.cc index 21e8527..16a1e7c 100644 --- a/src/plib/gnw/input.cc +++ b/src/plib/gnw/input.cc @@ -4,6 +4,7 @@ #include #include "audio_engine.h" +#include "platform_compat.h" #include "plib/color/color.h" #include "plib/gnw/button.h" #include "plib/gnw/dxinput.h" @@ -507,7 +508,7 @@ int default_screendump(int width, int height, unsigned char* data, unsigned char for (index = 0; index < 100000; index++) { snprintf(fileName, sizeof(fileName), "scr%.5d.bmp", index); - stream = fopen(fileName, "rb"); + stream = compat_fopen(fileName, "rb"); if (stream == NULL) { break; } @@ -519,7 +520,7 @@ int default_screendump(int width, int height, unsigned char* data, unsigned char return -1; } - stream = fopen(fileName, "wb"); + stream = compat_fopen(fileName, "wb"); if (stream == NULL) { return -1; }