From 3aac89e8a9d1c1f538001f36f0c75ac05c4f5f79 Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Sun, 19 Nov 2023 15:28:52 +0100 Subject: [PATCH] bugfix: macOS did not have IPF support (fixes #1126) The capsimg.so wasn't copied in the bundle, and even if it was, the path was incorrect under macOS. This implementation is not necessarily according to macOS "standards", since I've copied capsimg.so in the same location the binary is in, but it does work. :) --- src/dlopen.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/dlopen.cpp b/src/dlopen.cpp index 86c1ffb8f..f007d3d2f 100644 --- a/src/dlopen.cpp +++ b/src/dlopen.cpp @@ -61,6 +61,9 @@ static amiga_plugin_lookup_function plugin_lookup; } #endif +#ifdef __MACH__ +#include +#endif UAE_DLHANDLE uae_dlopen_plugin(const TCHAR *name) { #if defined(AMIBERRY) @@ -73,7 +76,27 @@ UAE_DLHANDLE uae_dlopen_plugin(const TCHAR *name) return NULL; } */ +#ifdef __MACH__ + char exepath[MAX_DPATH]; + uint32_t size = sizeof exepath; + std::string directory; + if (_NSGetExecutablePath(exepath, &size) == 0) + { + size_t last_slash_idx = string(exepath).rfind('/'); + if (std::string::npos != last_slash_idx) + { + directory = string(exepath).substr(0, last_slash_idx); + } + last_slash_idx = directory.rfind('/'); + if (std::string::npos != last_slash_idx) + { + directory = directory.substr(0, last_slash_idx); + } + } + UAE_DLHANDLE handle = uae_dlopen(directory.append("/MacOS/capsimg.so").c_str()); +#else UAE_DLHANDLE handle = uae_dlopen("./capsimg.so"); +#endif // __MACH__ #elif defined(WINUAE) TCHAR path[MAX_DPATH]; _tcscpy(path, name);