* platform: Honor the LIBRETRO_CHEATS_DIRECTORY environment variable. (#17440)

* frontend/drivers/platform_unix.c
(libretro_cheats_directory): New variable.
(frontend_unix_get_env): Set DEFAULT_DIR_CHEATS to the value of
the LIBRETRO_CHEATS_DIRECTORY environment variable, if available.
* frontend/drivers/platform_win32.c: Likewise.
* configuration.c (config_load_file)
<libretro_cheats_directory>: New variable. Use the values of
the LIBRETRO_CHEATS_DIRECTORY environment variables instead of their
corresponding configured values, when set.
* docs/retroarch.6: Document it.
* retroarch.c (retroarch_print_help): Extend help text.
This commit is contained in:
Apteryks 2025-01-20 14:08:45 +00:00 committed by GitHub
parent 4020326f58
commit 52320dfaa8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 31 additions and 5 deletions

View File

@ -3571,6 +3571,7 @@ static bool config_load_file(global_t *global,
char* libretro_directory = NULL;
char* libretro_assets_directory = NULL;
char* libretro_autoconfig_directory = NULL;
char* libretro_cheats_directory = NULL;
char* libretro_database_directory = NULL;
char* libretro_system_directory = NULL;
char* libretro_video_filter_directory = NULL;
@ -3883,6 +3884,12 @@ static bool config_load_file(global_t *global,
settings->paths.directory_autoconfig,
libretro_autoconfig_directory);
libretro_cheats_directory = getenv("LIBRETRO_CHEATS_DIRECTORY");
if (libretro_cheats_directory) /* override configuration value */
configuration_set_string(settings,
settings->paths.path_cheat_database,
libretro_cheats_directory);
libretro_database_directory = getenv("LIBRETRO_DATABASE_DIRECTORY");
if (libretro_database_directory) /* override configuration value */
configuration_set_string(settings,

View File

@ -1,6 +1,6 @@
.\" retroarch.6:
.TH "RETROARCH" "6" "January 18, 2025" "RETROARCH" "System Manager's Manual: retroarch"
.TH "RETROARCH" "6" "January 20, 2025" "RETROARCH" "System Manager's Manual: retroarch"
.SH NAME
@ -261,6 +261,12 @@ Specify the directory where RetroArch looks for controller
auto-configuration files, overriding the value of the
"joypad_autoconfig_dir" configuration file option.
.TP
\fBLIBRETRO_CHEATS_DIRECTORY\fR
Specify the directory where RetroArch looks for cheat files,
overriding the value of the "cheat_database_path" configuration file
option.
.TP
\fBLIBRETRO_DATABASE_DIRECTORY\fR
Specify the directory where RetroArch looks for database files,

View File

@ -1325,6 +1325,7 @@ static void frontend_unix_get_env(int *argc,
const char* libretro_directory = getenv("LIBRETRO_DIRECTORY");
const char* libretro_assets_directory = getenv("LIBRETRO_ASSETS_DIRECTORY");
const char* libretro_autoconfig_directory = getenv("LIBRETRO_AUTOCONFIG_DIRECTORY");
const char* libretro_cheats_directory = getenv("LIBRETRO_CHEATS_DIRECTORY");
const char* libretro_database_directory = getenv("LIBRETRO_DATABASE_DIRECTORY");
const char* libretro_system_directory = getenv("LIBRETRO_SYSTEM_DIRECTORY");
const char* libretro_video_filter_directory = getenv("LIBRETRO_VIDEO_FILTER_DIRECTORY");
@ -1904,8 +1905,13 @@ static void frontend_unix_get_env(int *argc,
else
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], base_path,
"shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER]));
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], base_path,
"cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
if (!string_is_empty(libretro_cheats_directory))
strlcpy(g_defaults.dirs[DEFAULT_DIR_CHEATS],
libretro_cheats_directory,
sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
else
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], base_path,
"cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], base_path,
"overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY]));
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OSK_OVERLAY], base_path,

View File

@ -568,6 +568,7 @@ static void frontend_win32_env_get(int *argc, char *argv[],
const char *libretro_directory = getenv("LIBRETRO_DIRECTORY");
const char *libretro_assets_directory = getenv("LIBRETRO_ASSETS_DIRECTORY");
const char* libretro_autoconfig_directory = getenv("LIBRETRO_AUTOCONFIG_DIRECTORY");
const char* libretro_cheats_directory = getenv("LIBRETRO_CHEATS_DIRECTORY");
const char* libretro_database_directory = getenv("LIBRETRO_DATABASE_DIRECTORY");
const char* libretro_system_directory = getenv("LIBRETRO_SYSTEM_DIRECTORY");
const char* libretro_video_filter_directory = getenv("LIBRETRO_VIDEO_FILTER_DIRECTORY");
@ -594,8 +595,13 @@ static void frontend_win32_env_get(int *argc, char *argv[],
else
fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER],
":\\filters\\video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER]));
fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CHEATS],
":\\cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
if (!string_is_empty(libretro_cheats_directory))
strlcpy(g_defaults.dirs[DEFAULT_DIR_CHEATS],
libretro_cheats_directory,
sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
else
fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CHEATS],
":\\cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS]));
if (!string_is_empty(libretro_database_directory))
strlcpy(g_defaults.dirs[DEFAULT_DIR_DATABASE],
libretro_database_directory,

View File

@ -6531,6 +6531,7 @@ static void retroarch_print_help(const char *arg0)
"\nThe following environment variables are supported:\n\n"
" LIBRETRO_ASSETS_DIRECTORY\n"
" LIBRETRO_AUTOCONFIG_DIRECTORY\n"
" LIBRETRO_CHEATS_DIRECTORY\n"
" LIBRETRO_DATABASE_DIRECTORY\n"
" LIBRETRO_DIRECTORY\n"
" LIBRETRO_SYSTEM_DIRECTORY\n"