summarylogtreecommitdiffstats
path: root/fix_base_path.patch
blob: b92f7e47dbe298c84265eb9e3b56229762c9f961 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
diff --git a/src/mcu.cpp b/src/mcu.cpp
index d5cc046..7951401 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++)