This commit is contained in:
twinaphex 2015-09-18 14:26:23 +02:00
parent e9cfd96acf
commit 560e706c7e

View File

@ -542,28 +542,16 @@ boolean HasTrailingSlash(const char* dn)
char* I_FindFile(const char* wfname, const char* ext)
{
FILE *file;
size_t pl;
char * p;
char slash;
/* Precalculate a length we will need in the loop */
pl = strlen(wfname) + strlen(ext) + 4;
if (log_cb)
log_cb(RETRO_LOG_INFO, "wfname: [%s], g_wad_dir: [%s]\n", wfname, g_wad_dir);
p = malloc(strlen(g_wad_dir) + pl);
#ifdef _WIN32
slash = '\\';
char slash = '\\';
#else
slash = '/';
char slash = '/';
#endif
if (log_cb)
log_cb(RETRO_LOG_INFO, "%s%c%s\n", g_wad_dir, slash, wfname);
sprintf(p, "%s%c%s", g_wad_dir, slash, wfname);
/* Precalculate a length we will need in the loop */
size_t pl = strlen(wfname) + strlen(ext) + 4;
char *p = malloc(strlen(g_wad_dir) + pl);
FILE *file = fopen(p, "rb");
file = fopen(p, "rb");
if (!file)
{
strcat(p, ext);
@ -572,8 +560,6 @@ char* I_FindFile(const char* wfname, const char* ext)
if (file)
{
if (log_cb)
log_cb(RETRO_LOG_INFO, " found %s\n", p);
fclose(file);
return p;
}