From bcbac7708480232bf2c39c6f61e73cec05c84b85 Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Thu, 14 May 2020 23:47:57 -0400 Subject: [PATCH] When a lua script is provided on the command line with the --loadlua option. Added code to always resolve any relative file path to an absolute as the lua core changes the current working directory which then invalidates the relative pathing from where the current working directory was at the time the program had initially been started. --- src/drivers/sdl/sdl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/drivers/sdl/sdl.cpp b/src/drivers/sdl/sdl.cpp index a4f7c5d8..9273d578 100644 --- a/src/drivers/sdl/sdl.cpp +++ b/src/drivers/sdl/sdl.cpp @@ -915,6 +915,15 @@ int main(int argc, char *argv[]) g_config->setOption("SDL.LuaScript", ""); if (s != "") { +#ifdef __linux + // Resolve absolute path to file + char fullpath[2048]; + if ( realpath( s.c_str(), fullpath ) != NULL ) + { + //printf("Fullpath: '%s'\n", fullpath ); + s.assign( fullpath ); + } +#endif FCEU_LoadLuaCode(s.c_str()); } #endif