From 4724318f3de81f1b943c634dde004032e452dda6 Mon Sep 17 00:00:00 2001 From: Paul Broadhead Date: Thu, 17 Oct 2024 17:52:10 +0100 Subject: [PATCH] Added a config option for an alternative updates path for data files. This is the full path to the directory, a trailing "/" will be added if needed. The path does not have to be within the el config tree so long as you have read access. The path is configurable from the server tab of options. --- elconfig.c | 1 + init.c | 2 ++ init.h | 1 + io/elpathwrapper.c | 5 ++++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/elconfig.c b/elconfig.c index bfbaef0c9..a8f309556 100755 --- a/elconfig.c +++ b/elconfig.c @@ -3156,6 +3156,7 @@ static void init_ELC_vars(void) SERVER); add_var(OPT_BOOL,"write_ini_on_exit", "wini", &write_ini_on_exit, change_var, 1,"Save INI","Save options when you quit",SERVER); add_var(OPT_STRING,"data_dir","dir",datadir,change_dir_name,90,"Data Directory","Place were we keep our data. Can only be changed with a Client restart.",SERVER); + add_var(OPT_STRING,"alt_updates_dir","aupdir",alt_updates_dir,change_dir_name,90,"Alt Updates Directory","Full path to an alternative updates directory for data files. Normally blank.",SERVER); #endif // ANDROID add_var(OPT_BOOL,"serverpopup","spu",&use_server_pop_win,change_var,1,"Use Special Text Window","Toggles whether server messages from channel 255 are displayed in a pop up window.",SERVER); /* Note: We don't take any action on the already-running thread, as that wouldn't necessarily be good. */ diff --git a/init.c b/init.c index dcd2c39c6..6cf2b4f29 100644 --- a/init.c +++ b/init.c @@ -113,6 +113,8 @@ char datadir[256]=DATA_DIR; char datadir[256]="./"; #endif //DATA_DIR +char alt_updates_dir[256]=""; + static const char *cfg_filename = "el.cfg"; #ifdef JSON_FILES static const char *client_state_filename = "client_state.json"; diff --git a/init.h b/init.h index c0e96586b..46cc766b3 100644 --- a/init.h +++ b/init.h @@ -251,6 +251,7 @@ typedef struct extern char configdir[256]; /*!< the default directory where we look for configuration files */ extern char datadir[256]; /*!< the default directory where we look for data files (aka installation dir) */ +extern char alt_updates_dir[256]; /*!< an alternative updates directory for data files, if blank, default is /updates/ */ /*! * \ingroup loadsave diff --git a/io/elpathwrapper.c b/io/elpathwrapper.c index 9f9c30afd..6796848af 100644 --- a/io/elpathwrapper.c +++ b/io/elpathwrapper.c @@ -192,7 +192,10 @@ const char * get_path_updates(void) return locbuffer; } - safe_snprintf(locbuffer, sizeof(locbuffer), "%supdates/%d_%d_%d/", get_path_config_base(), VER_MAJOR, VER_MINOR, VER_RELEASE); + if (alt_updates_dir[0] != '\0') + safe_snprintf(locbuffer, sizeof(locbuffer), "%s", alt_updates_dir); + else + safe_snprintf(locbuffer, sizeof(locbuffer), "%supdates/%d_%d_%d/", get_path_config_base(), VER_MAJOR, VER_MINOR, VER_RELEASE); return locbuffer; }