Use compat_fopen

This commit is contained in:
Alexander Batalov 2023-02-28 19:11:16 +03:00
parent a37415fd90
commit f66ac0f484
6 changed files with 16 additions and 15 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}
}

View File

@ -4,6 +4,7 @@
#include <stdio.h>
#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;
}