From 0df110d6db0cfdebeb87bc84b9f02d96224e1171 Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Sun, 28 Apr 2024 19:22:39 -0400 Subject: [PATCH] Fix base path on Linux When the path is /usr/bin/nuked-sc55, the absolute path must be used to determine the correct base path of /usr/share/nuked-sc55. --- src/mcu.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mcu.cpp b/src/mcu.cpp index d5cc046d..79514018 100644 --- a/src/mcu.cpp +++ b/src/mcu.cpp @@ -1404,21 +1404,23 @@ int main(int argc, char *argv[]) #if __linux__ char self_path[PATH_MAX]; + char self_path_absolute[PATH_MAX]; memset(&self_path[0], 0, PATH_MAX); + memset(&self_path_absolute[0], 0, PATH_MAX); if(readlink("/proc/self/exe", self_path, PATH_MAX) == -1) - basePath = Files::real_dirname(argv[0]); + basePath = Files::real_dirname(realpath(argv[0], self_path_absolute)); else - basePath = Files::dirname(self_path); + basePath = Files::dirname(realpath(self_path, self_path_absolute)); #else basePath = Files::real_dirname(argv[0]); #endif - printf("Base path is: %s\n", argv[0]); - if(Files::dirExists(basePath + "/../share/nuked-sc55")) basePath += "/../share/nuked-sc55"; + printf("Base path is: %s\n", basePath.c_str()); + if (autodetect) { for (size_t i = 0; i < ROM_SET_COUNT; i++)