Skip to content

Commit

Permalink
refactor: use Resources/plugins for plugins folder in MacOS
Browse files Browse the repository at this point in the history
Since the user cannot copy any non-signed plugins anyway, might as well make this internal
  • Loading branch information
midwan committed Dec 19, 2024
1 parent 357cb2d commit b043c32
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/osdep/amiberry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3930,7 +3930,23 @@ std::string get_config_directory(bool portable_mode)
std::string get_plugins_directory(bool portable_mode)
{
#ifdef __MACH__
return home_dir + "/Plugins/";
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);
}
}
return directory + "/Resources/plugins/";
#else
if (portable_mode)
{
Expand Down Expand Up @@ -4005,18 +4021,6 @@ void create_missing_amiberry_folders()
#endif
if (!my_existsdir(config_path.c_str()))
my_mkdir(config_path.c_str());
if (!my_existsdir(plugins_dir.c_str()))
{
my_mkdir(plugins_dir.c_str());
#ifdef __MACH__
const std::string bundled_plugins_path = app_directory + "/Resources/plugins/";
if (my_existsdir(bundled_plugins_path.c_str()))
{
const std::string command = "cp -r " + bundled_plugins_path + "* " + plugins_dir;
system(command.c_str());
}
#endif
}
if (!my_existsdir(controllers_path.c_str()))
{
my_mkdir(controllers_path.c_str());
Expand Down

0 comments on commit b043c32

Please sign in to comment.