From 4cea83fd1b9a3212df20a0bbc7d8724b473af990 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Sat, 23 Oct 2021 05:55:17 -0400 Subject: [PATCH] Changed command line lua script fullpath resolution logic to use cross platform QFileInfo instead of unix realpath. --- src/drivers/Qt/fceuWrapper.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index 8705490b..8084cad2 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include "Qt/main.h" #include "Qt/throttle.h" @@ -961,18 +962,27 @@ int fceuWrapperInit( int argc, char *argv[] ) // load lua script if option passed g_config->getOption("SDL.LuaScript", &s); g_config->setOption("SDL.LuaScript", ""); - if (s != "") + if (s.size() > 0) { -#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) + QFileInfo fi( s.c_str() ); // Resolve absolute path to file - char fullpath[2048]; - if ( realpath( s.c_str(), fullpath ) != NULL ) + if ( fi.exists() ) { - //printf("Fullpath: '%s'\n", fullpath ); - s.assign( fullpath ); + //printf("FI: '%s'\n", fi.absoluteFilePath().toStdString().c_str() ); + //printf("FI: '%s'\n", fi.canonicalFilePath().toStdString().c_str() ); + s = fi.canonicalFilePath().toStdString(); } -#endif +//#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) +// +// // 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