Skip to content

Commit

Permalink
bugfix: macOS did not have IPF support (fixes #1126)
Browse files Browse the repository at this point in the history
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. :)
  • Loading branch information
midwan committed Nov 19, 2023
1 parent 82bf938 commit 9f9e56a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/dlopen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ static amiga_plugin_lookup_function plugin_lookup;
}
#endif

#ifdef __MACH__
#include <mach-o/dyld.h>
#endif
UAE_DLHANDLE uae_dlopen_plugin(const TCHAR *name)
{
#if defined(AMIBERRY)
Expand All @@ -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);
Expand Down

0 comments on commit 9f9e56a

Please sign in to comment.