remove use of the config directory

the credentials and lan config files will now use the userdata folder
This commit is contained in:
pentarctagon 2024-07-04 14:08:44 -05:00 committed by Pentarctagon
parent a6a27ef947
commit f0991ec9c1
15 changed files with 7 additions and 100 deletions

View File

@ -121,7 +121,7 @@ jobs:
if: success() || steps.build.outcome == 'success'
run: |
./wesnoth --version
for opt in config data userconfig userdata
for opt in data userdata
do
output=$(./wesnoth --nobanner --"$opt"-path)
if [ "$output" = "" ]; then printf 'option --%s-path prints nothing to stdout!\n' "$opt" >&2; exit 1; fi

View File

@ -371,8 +371,6 @@
{_GUI_GAME_PATHS_ENTRY datadir ( _ "Game data:")}
{_GUI_GAME_PATHS_ENTRY config ( _ "Configuration:")}
{_GUI_GAME_PATHS_ENTRY userdata ( _ "User data:")}
{_GUI_GAME_PATHS_ENTRY saves ( _ "Saved games:")}

View File

@ -67,14 +67,6 @@ event.
.B --clock
Adds the option to show a clock for testing the drawing timer.
.TP
.BI --config-dir \ name
Deprecated, use
.BR --userdata-dir .
.TP
.B --config-path
Deprecated, use
.BR --userdata-path .
.TP
.BI --core \ id_core
overrides the loaded core with the one whose id is specified.
.TP
@ -354,19 +346,6 @@ package available to lua scripts, so that they can load arbitrary packages. Do n
sets the WML schema for use with
.BR -V,--validate .
.TP
.BI --userconfig-dir \ name
sets the user configuration directory to
.I name
under $HOME or "My Documents\\My Games" for windows.
You can also specify an absolute path for the configuration directory outside
the $HOME or "My Documents\\My Games". On Windows it is also possible to
specify a directory relative to the process working directory by using path
starting with ".\\" or "..\\".
This defaults to the userdata path.
.TP
.B --userconfig-path
prints the path of the user configuration directory and exits.
.TP
.BI --userdata-dir \ name
sets the userdata directory to
.I name

View File

@ -666,7 +666,6 @@ std::string full_build_report()
{
list_formatter::contents_list paths{
{"Data dir", game_config::path},
{"User config dir", filesystem::get_user_config_dir()},
{"User data dir", filesystem::get_user_data_dir()},
{"Saves dir", filesystem::get_saves_dir()},
{"Add-ons dir", filesystem::get_addons_dir()},

View File

@ -138,8 +138,6 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
, mptest(false)
, usercache_path(false)
, usercache_dir()
, userconfig_path(false)
, userconfig_dir()
, userdata_path(false)
, userdata_dir()
, validcache(false)
@ -170,8 +168,6 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
general_opts.add_options()
("all-translations", "Show all translations, even incomplete ones.")
("clock", "Adds the option to show a clock for testing the drawing timer.")
("config-dir", po::value<std::string>(), "sets the path of the userdata directory. DEPRECATED: use userdata-dir instead.")
("config-path", "prints the path of the userdata directory and exits. DEPRECATED: use userdata-path instead." IMPLY_TERMINAL)
("core", po::value<std::string>(), "overrides the loaded core with the one whose id is specified.")
("data-dir", po::value<std::string>(), "overrides the data directory with the one specified.")
("data-path", "prints the path of the data directory and exits." IMPLY_TERMINAL)
@ -205,8 +201,6 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
("unsafe-scripts", "makes the \'package\' package available to Lua scripts, so that they can load arbitrary packages. Do not do this with untrusted scripts! This action gives ua the same permissions as the Wesnoth executable.")
("usercache-dir", po::value<std::string>(), "sets the path of the cache directory to $HOME/<arg> or My Documents\\My Games\\<arg> for Windows. You can specify also an absolute path outside the $HOME or My Documents\\My Games directory. Defaults to $HOME/.cache/wesnoth on X11 and to the userdata-dir on other systems.")
("usercache-path", "prints the path of the cache directory and exits.")
("userconfig-dir", po::value<std::string>(), "sets the path of the user config directory. Defaults to the userdata-dir.")
("userconfig-path", "prints the path of the user config directory and exits.")
("userdata-dir", po::value<std::string>(), "sets the path of the userdata directory. You can use ~ to denote $HOME or My Documents\\My Games on Windows.")
("userdata-path", "prints the path of the userdata directory and exits." IMPLY_TERMINAL)
("username", po::value<std::string>(), "uses <username> when connecting to a server, ignoring other preferences.")
@ -330,10 +324,6 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
clock = true;
if(vm.count("core"))
core_id = vm["core"].as<std::string>();
if(vm.count("config-dir"))
userdata_dir = vm["config-dir"].as<std::string>(); //TODO: complain and remove
if(vm.count("config-path"))
userdata_path = true; //TODO: complain and remove
if(vm.count("controller"))
multiplayer_controller = parse_to_uint_string_tuples_(vm["controller"].as<std::vector<std::string>>());
if(vm.count("data-dir"))
@ -490,10 +480,6 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
usercache_dir = vm["usercache-dir"].as<std::string>();
if(vm.count("usercache-path"))
usercache_path = true;
if(vm.count("userconfig-dir"))
userconfig_dir = vm["userconfig-dir"].as<std::string>();
if(vm.count("userconfig-path"))
userconfig_path = true;
if(vm.count("userdata-dir"))
userdata_dir = vm["userdata-dir"].as<std::string>();
if(vm.count("userdata-path"))

View File

@ -208,10 +208,6 @@ public:
bool usercache_path;
/** Non-empty if --usercache-dir was given on the command line. Sets the cache dir to the specified one. */
std::optional<std::string> usercache_dir;
/** True if --userconfig-path was given on the command line. Prints path to user config directory and exits. */
bool userconfig_path;
/** Non-empty if --userconfig-dir was given on the command line. Sets the user config dir to the specified one. */
std::optional<std::string> userconfig_dir;
/** True if --userdata-path was given on the command line. Prints path to user data directory and exits. */
bool userdata_path;
/** Non-empty if --userdata-dir was given on the command line. Sets the user data dir to the specified one. */

View File

@ -200,7 +200,6 @@ std::vector<path_info> game_paths(std::set<GAME_PATH_TYPES> paths)
static const std::string& game_bin_dir = pretty_path(filesystem::get_exe_dir());
static const std::string& game_data_dir = pretty_path(game_config::path);
static const std::string& game_user_data_dir = pretty_path(filesystem::get_user_data_dir());
static const std::string& game_user_pref_dir = pretty_path(filesystem::get_user_config_dir());
static const std::string& game_editor_map_dir = pretty_path(filesystem::get_legacy_editor_dir() + "/maps");
std::vector<path_info> res;
@ -217,10 +216,6 @@ std::vector<path_info> game_paths(std::set<GAME_PATH_TYPES> paths)
res.push_back({{ N_("filesystem_path_game^User data"), GETTEXT_DOMAIN }, "", game_user_data_dir});
}
if(paths.count(GAME_USER_PREFS_DIR) > 0 && !have_path(res, game_user_pref_dir)) {
res.push_back({{ N_("filesystem_path_game^User preferences"), GETTEXT_DOMAIN }, "", game_user_pref_dir});
}
if(paths.count(GAME_EDITOR_MAP_DIR) > 0 && !have_path(res, game_editor_map_dir)) {
res.push_back({{ N_("filesystem_path_game^Editor maps"), GETTEXT_DOMAIN }, "", game_editor_map_dir});
}

View File

@ -57,7 +57,6 @@ enum GAME_PATH_TYPES
{
GAME_BIN_DIR = 0, /**< Game executable dir. */
GAME_CORE_DATA_DIR = 1, /**< Game data dir. */
GAME_USER_PREFS_DIR = 2, /**< User preferences dir. */
GAME_USER_DATA_DIR = 3, /**< User data dir. */
GAME_EDITOR_MAP_DIR = 4, /**< Editor map dir */
};

View File

@ -568,7 +568,7 @@ std::string get_next_filename(const std::string& name, const std::string& extens
return next_filename;
}
static bfs::path user_data_dir, user_config_dir, cache_dir;
static bfs::path user_data_dir, cache_dir;
bool is_userdata_initialized()
{
@ -892,19 +892,6 @@ bool rename_dir(const std::string& old_dir, const std::string& new_dir)
return true;
}
static void set_user_config_path(bfs::path newconfig)
{
user_config_dir = newconfig;
if(!create_directory_if_missing_recursive(user_config_dir)) {
ERR_FS << "could not open or create user config directory at " << user_config_dir.string();
}
}
void set_user_config_dir(const std::string& newconfigdir)
{
set_user_config_path(newconfigdir);
}
static void set_cache_path(bfs::path newcache)
{
cache_dir = newcache;
@ -927,15 +914,6 @@ static const bfs::path& get_user_data_path()
return user_data_dir;
}
std::string get_user_config_dir()
{
if(user_config_dir.empty()) {
user_config_dir = get_user_data_path();
}
return user_config_dir.string();
}
std::string get_user_data_dir()
{
return get_user_data_path().string();

View File

@ -167,11 +167,9 @@ const std::string& get_version_path_suffix();
std::string get_next_filename(const std::string& name, const std::string& extension);
bool is_userdata_initialized();
void set_user_config_dir(const std::string& path);
void set_user_data_dir(std::string path);
void set_cache_dir(const std::string& path);
std::string get_user_config_dir();
std::string get_user_data_dir();
std::string get_logs_dir();
std::string get_cache_dir();

View File

@ -134,7 +134,7 @@ std::string get_unsynced_prefs_file()
std::string get_credentials_file()
{
return get_user_config_dir() + "/credentials-aes";
return get_user_data_dir() + "/credentials-aes";
}
std::string get_default_prefs_file()

View File

@ -21,7 +21,7 @@
#include "config.hpp" // for config, etc
#include "cursor.hpp" // for set, CURSOR_TYPE::NORMAL
#include "exceptions.hpp" // for error
#include "filesystem.hpp" // for get_user_config_dir, etc
#include "filesystem.hpp" // for get_user_data_dir, etc
#include "game_classification.hpp" // for game_classification, etc
#include "game_config.hpp" // for path, no_delay, revision, etc
#include "game_config_manager.hpp" // for game_config_manager
@ -253,7 +253,6 @@ game_launcher::game_launcher(const commandline_options& cmdline_opts)
if(!cmdline_opts.nobanner) {
PLAIN_LOG
<< "\nData directory: " << game_config::path
<< "\nUser configuration directory: " << filesystem::get_user_config_dir()
<< "\nUser data directory: " << filesystem::get_user_data_dir()
<< "\nCache directory: " << filesystem::get_cache_dir()
<< "\n\n";
@ -824,7 +823,7 @@ void game_launcher::start_wesnothd()
wesnothd_program = filesystem::get_wesnothd_name();
}
std::string config = filesystem::get_user_config_dir() + "/lan_server.cfg";
std::string config = filesystem::get_user_data_dir() + "/lan_server.cfg";
if (!filesystem::file_exists(config)) {
// copy file if it isn't created yet
filesystem::write_file(config, filesystem::read_file(filesystem::get_wml_location("lan_server.cfg")));

View File

@ -66,7 +66,6 @@ game_version::game_version(unsigned start_page)
// NOTE: these path_map_ entries are referenced by the GUI2 WML
// definition of this dialog using preprocessor macros.
path_map_["datadir"] = game_config::path;
path_map_["config"] = filesystem::get_user_config_dir();
path_map_["userdata"] = filesystem::get_user_data_dir();
path_map_["saves"] = filesystem::get_saves_dir();
path_map_["addons"] = filesystem::get_addons_dir();

View File

@ -77,8 +77,6 @@ BOOST_AUTO_TEST_CASE (test_empty_options)
BOOST_CHECK(!co.screenshot_map_file);
BOOST_CHECK(!co.screenshot_output_file);
BOOST_CHECK(!co.test);
BOOST_CHECK(!co.userconfig_dir);
BOOST_CHECK(!co.userconfig_path);
BOOST_CHECK(!co.userdata_dir);
BOOST_CHECK(!co.userdata_path);
BOOST_CHECK(!co.validcache);
@ -150,8 +148,6 @@ BOOST_AUTO_TEST_CASE (test_default_options)
BOOST_CHECK(!co.screenshot_map_file);
BOOST_CHECK(!co.screenshot_output_file);
BOOST_CHECK(co.test && co.test->empty());
BOOST_CHECK(!co.userconfig_dir);
BOOST_CHECK(!co.userconfig_path);
BOOST_CHECK(!co.userdata_dir);
BOOST_CHECK(!co.userdata_path);
BOOST_CHECK(!co.validcache);
@ -219,8 +215,6 @@ BOOST_AUTO_TEST_CASE (test_full_options)
"--server=servfoo",
"--test=testfoo",
"--turns=42",
"--userconfig-dir=userconfigdirfoo",
"--userconfig-path",
"--userdata-dir=userdatadirfoo",
"--userdata-path",
"--validcache",
@ -303,8 +297,6 @@ BOOST_AUTO_TEST_CASE (test_full_options)
BOOST_CHECK(co.screenshot && co.screenshot_map_file && co.screenshot_output_file);
BOOST_CHECK(*co.screenshot_map_file == "mapfoo" && *co.screenshot_output_file == "outssfoo");
BOOST_CHECK(co.test && *co.test == "testfoo");
BOOST_CHECK(co.userconfig_dir && *co.userconfig_dir == "userconfigdirfoo");
BOOST_CHECK(co.userconfig_path);
BOOST_CHECK(co.userdata_dir && *co.userdata_dir == "userdatadirfoo");
BOOST_CHECK(co.userdata_path);
BOOST_CHECK(co.validcache);
@ -372,8 +364,6 @@ BOOST_AUTO_TEST_CASE (test_positional_options)
BOOST_CHECK(!co.screenshot_map_file);
BOOST_CHECK(!co.screenshot_output_file);
BOOST_CHECK(!co.test);
BOOST_CHECK(!co.userconfig_dir);
BOOST_CHECK(!co.userconfig_path);
BOOST_CHECK(!co.userdata_dir);
BOOST_CHECK(!co.userdata_path);
BOOST_CHECK(!co.validcache);

View File

@ -286,10 +286,6 @@ static int process_command_args(const commandline_options& cmdline_opts)
filesystem::set_cache_dir(*cmdline_opts.usercache_dir);
}
if(cmdline_opts.userconfig_dir) {
filesystem::set_user_config_dir(*cmdline_opts.userconfig_dir);
}
if(cmdline_opts.userdata_dir) {
filesystem::set_user_data_dir(*cmdline_opts.userdata_dir);
}
@ -304,11 +300,6 @@ static int process_command_args(const commandline_options& cmdline_opts)
return 0;
}
if(cmdline_opts.userconfig_path) {
std::cout << filesystem::get_user_config_dir();
return 0;
}
if(cmdline_opts.userdata_path) {
std::cout << filesystem::get_user_data_dir();
return 0;
@ -950,8 +941,8 @@ int main(int argc, char** argv)
for(const auto& arg : args) {
// Switches that don't take arguments
static const std::set<std::string> terminal_switches = {
"--config-path", "--data-path", "-h", "--help", "--logdomains", "--nogui", "-R", "--report",
"--simple-version", "--userconfig-path", "--userdata-path", "-v", "--version"
"--data-path", "-h", "--help", "--logdomains", "--nogui", "-R", "--report",
"--simple-version", "--userdata-path", "-v", "--version"
};
// Switches that take arguments, the switch may have the argument past