Lua scripting pathing improvements for Linux/MacOS. Use realpath when possible to always have a absolute path for scripts and roms internally.

This commit is contained in:
Matthew Budd 2020-10-31 16:25:29 -04:00
parent 0cca02e765
commit 5c29bdbd8d
2 changed files with 3 additions and 8 deletions

View File

@ -753,7 +753,8 @@ int fceuWrapperInit( int argc, char *argv[] )
g_config->setOption("SDL.LuaScript", ""); g_config->setOption("SDL.LuaScript", "");
if (s != "") if (s != "")
{ {
#ifdef __linux #if defined(__linux) || defined(__APPLE__)
// Resolve absolute path to file // Resolve absolute path to file
char fullpath[2048]; char fullpath[2048];
if ( realpath( s.c_str(), fullpath ) != NULL ) if ( realpath( s.c_str(), fullpath ) != NULL )

View File

@ -618,16 +618,10 @@ static int emu_loadrom(lua_State *L)
const char *nameo2 = luaL_checkstring(L,1); const char *nameo2 = luaL_checkstring(L,1);
char nameo[2048]; char nameo[2048];
if ( nameo2[0] == '/' ) if ( realpath( nameo2, nameo ) == NULL )
{ {
strncpy(nameo, nameo2, sizeof(nameo)); strncpy(nameo, nameo2, sizeof(nameo));
} }
else
{
char cwd[1024];
getcwd( cwd, sizeof(cwd) );
snprintf( nameo, sizeof(nameo), "%s/%s", cwd, nameo2 );
}
//printf("Load ROM: '%s'\n", nameo ); //printf("Load ROM: '%s'\n", nameo );
if (!LoadGame(nameo, true)) if (!LoadGame(nameo, true))
{ {