EXEC: Search for CFG by file path

This commit is contained in:
mazmazz 2018-12-13 13:11:25 -05:00
parent 1029463741
commit 93eda4e7c9
1 changed files with 15 additions and 3 deletions

View File

@ -32,6 +32,7 @@
#include "hu_stuff.h" #include "hu_stuff.h"
#include "p_setup.h" #include "p_setup.h"
#include "lua_script.h" #include "lua_script.h"
#include "d_netfil.h" // findfile
//======== //========
// protos. // protos.
@ -641,6 +642,7 @@ static void COM_CEchoDuration_f(void)
static void COM_Exec_f(void) static void COM_Exec_f(void)
{ {
UINT8 *buf = NULL; UINT8 *buf = NULL;
char filename[256];
if (COM_Argc() < 2 || COM_Argc() > 3) if (COM_Argc() < 2 || COM_Argc() > 3)
{ {
@ -649,13 +651,23 @@ static void COM_Exec_f(void)
} }
// load file // load file
// Try with Argv passed verbatim first, for back compat
FIL_ReadFile(COM_Argv(1), &buf); FIL_ReadFile(COM_Argv(1), &buf);
if (!buf) if (!buf)
{ {
if (!COM_CheckParm("-noerror")) // Now try by searching the file path
CONS_Printf(M_GetText("couldn't execute file %s\n"), COM_Argv(1)); // filename is modified with the full found path
return; strcpy(filename, COM_Argv(1));
if (findfile(filename, NULL, true) != FS_NOTFOUND)
FIL_ReadFile(filename, &buf);
if (!buf)
{
if (!COM_CheckParm("-noerror"))
CONS_Printf(M_GetText("couldn't execute file %s\n"), COM_Argv(1));
return;
}
} }
if (!COM_CheckParm("-silent")) if (!COM_CheckParm("-silent"))