diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index eddda212e240..0266397c5a31 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -1377,6 +1377,7 @@ static void frontend_unix_get_env(int *argc, char *argv[], void *data, void *params_data) { unsigned i; + const char* libretro_directory = getenv("LIBRETRO_DIRECTORY"); #ifdef ANDROID int32_t major, minor, rel; char device_model[PROP_VALUE_MAX] = {0}; @@ -1819,8 +1820,12 @@ static void frontend_unix_get_env(int *argc, strcpy_literal(base_path, "retroarch"); #endif - fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path, - "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + if (!string_is_empty(libretro_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE], libretro_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + else + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path, + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); #if defined(DINGUX) /* On platforms that require manual core installation/ * removal, placing core info files in the same directory diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 91168a34bb97..9b6f53c4192d 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -571,6 +571,7 @@ static void frontend_win32_env_get(int *argc, char *argv[], void *args, void *params_data) { const char *tmp_dir = getenv("TMP"); + const char *libretro_directory = getenv("LIBRETRO_DIRECTORY"); if (!string_is_empty(tmp_dir)) fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CACHE], tmp_dir, sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE])); @@ -609,8 +610,12 @@ static void frontend_win32_env_get(int *argc, char *argv[], fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT], ":\\layouts", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_LAYOUT])); #endif - fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE], - ":\\cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + if (!string_is_empty(libretro_directory)) + strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE], libretro_directory, + sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + else + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE], + ":\\cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], ":\\info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG],