Skip to content

Commit

Permalink
frontend: Honor the LIBRETRO_ASSETS_DIRECTORY environment variable.
Browse files Browse the repository at this point in the history
This builds on 763fcd8 ("unix, win32: Allow set the default
libretro_directory via environment variable") to also allow specifying
the assets directory via an environment variable.

* frontend/drivers/platform_unix.c (frontend_unix_get_env)
<libretro_assets_directory> New variable. Use it to set
DEFAULT_DIR_ASSETS, when available.
* frontend/drivers/platform_win32.c (frontend_win32_env_get): Likewise.
  • Loading branch information
Apteryks committed Sep 27, 2024
1 parent 8f09d98 commit b5ac44e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion frontend/drivers/platform_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,7 @@ static void frontend_unix_get_env(int *argc,
{
unsigned i;
const char* libretro_directory = getenv("LIBRETRO_DIRECTORY");
const char* libretro_assets_directory = getenv("LIBRETRO_ASSETS_DIRECTORY");
#ifdef ANDROID
int32_t major, minor, rel;
char device_model[PROP_VALUE_MAX] = {0};
Expand Down Expand Up @@ -1778,7 +1779,10 @@ static void frontend_unix_get_env(int *argc,
"assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
else
#endif
if (path_is_directory("/usr/local/share/retroarch/assets"))
if (!string_is_empty(libretro_assets_directory))
strlcpy(g_defaults.dirs[DEFAULT_DIR_ASSETS], libretro_assets_directory,
sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
else if (path_is_directory("/usr/local/share/retroarch/assets"))
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS],
"/usr/local/share/retroarch",
"assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
Expand Down
10 changes: 8 additions & 2 deletions frontend/drivers/platform_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,20 @@ static void frontend_win32_env_get(int *argc, char *argv[],
{
const char *tmp_dir = getenv("TMP");
const char *libretro_directory = getenv("LIBRETRO_DIRECTORY");
const char *libretro_assets_directory = getenv("LIBRETRO_ASSETS_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]));

gfx_set_dwm();

fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_ASSETS],
":\\assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
if (!string_is_empty(libretro_assets_directory))
strlcpy(g_defaults.dirs[DEFAULT_DIR_ASSETS], libretro_assets_directory,
sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
else
fill_pathname_expand_special(
g_defaults.dirs[DEFAULT_DIR_ASSETS],
":\\assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS]));
fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER],
":\\filters\\audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER]));
fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER],
Expand Down

0 comments on commit b5ac44e

Please sign in to comment.