Move data that should be synced between computers to a common dir

Fixes #8059
This commit is contained in:
pentarctagon 2024-06-11 11:09:27 -05:00 committed by Pentarctagon
parent 56afa893bb
commit 80fe9ba84d
4 changed files with 34 additions and 6 deletions

View file

@ -642,6 +642,7 @@ static void setup_user_data_dir()
// TODO: this may not print the error message if the directory exists but we don't have the proper permissions
// Create user data and add-on directories
create_directory_if_missing(get_sync_dir());
create_directory_if_missing(get_legacy_editor_dir());
create_directory_if_missing(get_legacy_editor_dir() + "/maps");
create_directory_if_missing(get_legacy_editor_dir() + "/scenarios");
@ -651,6 +652,10 @@ static void setup_user_data_dir()
create_directory_if_missing(get_wml_persist_dir());
create_directory_if_missing(get_logs_dir());
if(file_exists(get_unsynced_prefs_file()) && !file_exists(get_prefs_file())) {
copy_file(get_unsynced_prefs_file(), get_prefs_file());
}
lg::move_log_file();
}

View file

@ -133,11 +133,19 @@ void get_files_in_dir(const std::string &dir,
std::string get_dir(const std::string &dir);
// The location of various important files:
// The location of various important files/folders:
std::string get_prefs_file();
/** location of preferences file before it was moved to the sync directory */
std::string get_unsynced_prefs_file();
std::string get_credentials_file();
std::string get_default_prefs_file();
std::string get_save_index_file();
std::string get_lua_history_file();
/**
* parent directory for everything that should be synced between systems.
* implemented due to limitations of Steam's AutoCloud (non-SDK) syncing, but will also simplify things if it's ever added for any other platforms.
*/
std::string get_sync_dir();
std::string get_saves_dir();
std::string get_wml_persist_dir();
std::string get_intl_dir();

View file

@ -124,7 +124,12 @@ bool blacklist_pattern_list::match_dir(const std::string& name) const
std::string get_prefs_file()
{
return get_user_config_dir() + "/preferences";
return get_sync_dir() + "/preferences";
}
std::string get_unsynced_prefs_file()
{
return get_user_data_dir() + "/preferences";
}
std::string get_credentials_file()
@ -146,9 +151,19 @@ std::string get_save_index_file()
return get_user_data_dir() + "/save_index";
}
std::string get_lua_history_file()
{
return get_sync_dir() + "/lua_command_history";
}
std::string get_sync_dir()
{
return get_user_data_dir() + "/sync";
}
std::string get_saves_dir()
{
const std::string dir_path = get_user_data_dir() + "/saves";
const std::string dir_path = get_sync_dir() + "/saves";
return get_dir(dir_path);
}
@ -166,13 +181,13 @@ std::string get_addons_dir()
std::string get_wml_persist_dir()
{
const std::string dir_path = get_user_data_dir() + "/persist";
const std::string dir_path = get_sync_dir() + "/persist";
return get_dir(dir_path);
}
std::string get_legacy_editor_dir()
{
const std::string dir_path = get_user_data_dir() + "/editor";
const std::string dir_path = get_sync_dir() + "/editor";
return get_dir(dir_path);
}

View file

@ -188,7 +188,7 @@ public:
: prefix_()
, end_of_history_(true)
#ifdef HAVE_HISTORY
, filename_(filesystem::get_user_config_dir() + "/lua_command_history")
, filename_(filesystem::get_lua_history_file())
{
using_history();
read_history (filename_.c_str());