Skip to content

Commit

Permalink
unix, win32: Allow set the default libretro_directory via environment…
Browse files Browse the repository at this point in the history
… variable (#12040)
  • Loading branch information
Sou Bunnbu authored Feb 4, 2022
1 parent d43b99c commit 763fcd8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions frontend/drivers/platform_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions frontend/drivers/platform_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit 763fcd8

Please sign in to comment.