mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-16 02:15:19 +00:00
Make cache directory configurable too.
This commit is contained in:
parent
314f6f7c78
commit
48a10d9f7f
@ -28,6 +28,7 @@
|
||||
* Fixed inconsistent cropping of unusually-sized item images (issue #6118)
|
||||
* Fixed the `{IS_HERO}` macro to avoid losing the hero ellipse when a unit levels up
|
||||
* Stored credentials are now encrypted with AES rather than RC4. This will result in credentials needing to be re-entered the first time when logging in with this version.
|
||||
* The cache directory is now configurable through a command-line option in the same way as data, user data and user config directories.
|
||||
|
||||
## Version 1.17.6
|
||||
### Campaigns
|
||||
|
@ -1321,6 +1321,9 @@
|
||||
name = "Groggy Dice (groggydice)"
|
||||
comment = "wmllint enhancements"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Guillaume Lestringant"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Guorui Xi (Kevin_Xi)"
|
||||
email = "kevin_DOT_xgr_AT_gmail_DOT_com"
|
||||
|
@ -145,6 +145,8 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
|
||||
, headless_unit_test(false)
|
||||
, noreplaycheck(false)
|
||||
, mptest(false)
|
||||
, usercache_path(false)
|
||||
, usercache_dir()
|
||||
, userconfig_path(false)
|
||||
, userconfig_dir()
|
||||
, userdata_path(false)
|
||||
@ -214,6 +216,8 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
|
||||
("strict-validation", "makes validation errors fatal")
|
||||
("translations-over", po::value<unsigned int>(), "Specify the standard for determining whether a translation is complete.")
|
||||
("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 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/.config/wesnoth on X11 and to the userdata-dir on other systems.")
|
||||
("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 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.")
|
||||
@ -509,6 +513,10 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
|
||||
multiplayer_turns = vm["turns"].as<std::string>();
|
||||
if (vm.count("strict-validation"))
|
||||
strict_validation = true;
|
||||
if (vm.count("usercache-dir"))
|
||||
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"))
|
||||
|
@ -210,6 +210,10 @@ public:
|
||||
bool noreplaycheck;
|
||||
/** True if --mp-test was given on the command line. */
|
||||
bool mptest;
|
||||
/** True if --usercache-path was given on the command line. Prints path to cache directory and exits. */
|
||||
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. */
|
||||
|
@ -753,6 +753,19 @@ 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;
|
||||
if(!create_directory_if_missing_recursive(cache_dir)) {
|
||||
ERR_FS << "could not open or create cache directory at " << cache_dir.string() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
void set_cache_dir(const std::string& newcachedir)
|
||||
{
|
||||
set_cache_path(newcachedir);
|
||||
}
|
||||
|
||||
static const bfs::path& get_user_data_path()
|
||||
{
|
||||
if(user_data_dir.empty()) {
|
||||
|
@ -162,6 +162,7 @@ const std::string& get_version_path_suffix();
|
||||
std::string get_next_filename(const std::string& name, const std::string& extension);
|
||||
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();
|
||||
|
@ -379,6 +379,15 @@ static int process_command_args(const commandline_options& cmdline_opts)
|
||||
}
|
||||
}
|
||||
|
||||
if(cmdline_opts.usercache_dir) {
|
||||
filesystem::set_cache_dir(*cmdline_opts.usercache_dir);
|
||||
}
|
||||
|
||||
if(cmdline_opts.usercache_path) {
|
||||
PLAIN_LOG << filesystem::get_cache_dir();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(cmdline_opts.userconfig_dir) {
|
||||
filesystem::set_user_config_dir(*cmdline_opts.userconfig_dir);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user