windows: move config.yml and games.yml to /config/

This commit is contained in:
Megamouse 2025-01-02 12:24:25 +01:00
parent 5c2c4a6649
commit 451e953d26
20 changed files with 76 additions and 94 deletions

View file

@ -25,7 +25,7 @@ void cfg_ipc::load()
void cfg_ipc::save() const
{
#ifdef _WIN32
const std::string path_to_cfg = fs::get_config_dir() + "config/";
const std::string path_to_cfg = fs::get_config_dir(true);
if (!fs::create_path(path_to_cfg))
{
IPC.error("Could not create path: %s", path_to_cfg);
@ -42,11 +42,7 @@ void cfg_ipc::save() const
std::string cfg_ipc::get_path()
{
#ifdef _WIN32
return fs::get_config_dir() + "config/ipc.yml";
#else
return fs::get_config_dir() + "ipc.yml";
#endif
return fs::get_config_dir(true) + "ipc.yml";
}
bool cfg_ipc::get_server_enabled() const

View file

@ -8,11 +8,7 @@ cfg_camera g_cfg_camera;
cfg_camera::cfg_camera()
: cfg::node()
#ifdef _WIN32
, path(fs::get_config_dir() + "config/camera.yml")
#else
, path(fs::get_config_dir() + "camera.yml")
#endif
, path(fs::get_config_dir(true) + "camera.yml")
{
}

View file

@ -235,7 +235,7 @@ struct emulated_pads_config : cfg::node
m_mutex.lock();
bool result = false;
const std::string cfg_name = fmt::format("%sconfig/%s.yml", fs::get_config_dir(), cfg_id);
const std::string cfg_name = fmt::format("%s%s.yml", fs::get_config_dir(true), cfg_id);
cfg_log.notice("Loading %s config: %s", cfg_id, cfg_name);
from_default();
@ -272,7 +272,7 @@ struct emulated_pads_config : cfg::node
{
std::lock_guard lock(m_mutex);
const std::string cfg_name = fmt::format("%sconfig/%s.yml", fs::get_config_dir(), cfg_id);
const std::string cfg_name = fmt::format("%s%s.yml", fs::get_config_dir(true), cfg_id);
cfg_log.notice("Saving %s config to '%s'", cfg_id, cfg_name);
if (!fs::create_path(fs::get_parent_dir(cfg_name)))

View file

@ -4,11 +4,7 @@
#include "Utilities/File.h"
mouse_config::mouse_config()
#ifdef _WIN32
: cfg_name(fs::get_config_dir() + "config/config_mouse.yml")
#else
: cfg_name(fs::get_config_dir() + "config_mouse.yml")
#endif
: cfg_name(fs::get_config_dir(true) + "config_mouse.yml")
{
}

View file

@ -8,13 +8,7 @@ cfg_rb3drums g_cfg_rb3drums;
cfg_rb3drums::cfg_rb3drums()
: cfg::node()
#ifdef _WIN32
,
path(fs::get_config_dir() + "config/rb3drums.yml")
#else
,
path(fs::get_config_dir() + "rb3drums.yml")
#endif
, path(fs::get_config_dir(true) + "rb3drums.yml")
{
}

View file

@ -8,11 +8,7 @@ cfg_recording g_cfg_recording;
cfg_recording::cfg_recording()
: cfg::node()
#ifdef _WIN32
, path(fs::get_config_dir() + "config/recording.yml")
#else
, path(fs::get_config_dir() + "recording.yml")
#endif
, path(fs::get_config_dir(true) + "recording.yml")
{
}

View file

@ -59,11 +59,7 @@ namespace np
{
std::string get_players_history_path()
{
#ifdef _WIN32
return fs::get_config_dir() + "config/players_history.yml";
#else
return fs::get_config_dir() + "players_history.yml";
#endif
return fs::get_config_dir(true) + "players_history.yml";
}
std::map<std::string, player_history> load_players_history()
@ -1440,7 +1436,7 @@ namespace np
void np_handler::save_players_history()
{
#ifdef _WIN32
const std::string path_to_cfg = fs::get_config_dir() + "config/";
const std::string path_to_cfg = fs::get_config_dir(true);
if (!fs::create_path(path_to_cfg))
{
nph_log.error("Could not create path: %s", path_to_cfg);

View file

@ -34,7 +34,7 @@ void cfg_rpcn::load()
void cfg_rpcn::save() const
{
#ifdef _WIN32
const std::string path_to_cfg = fs::get_config_dir() + "config/";
const std::string path_to_cfg = fs::get_config_dir(true);
if (!fs::create_path(path_to_cfg))
{
rpcn_log.error("Could not create path: %s", path_to_cfg);
@ -51,11 +51,7 @@ void cfg_rpcn::save() const
std::string cfg_rpcn::get_path()
{
#ifdef _WIN32
return fs::get_config_dir() + "config/rpcn.yml";
#else
return fs::get_config_dir() + "rpcn.yml";
#endif
return fs::get_config_dir(true) + "rpcn.yml";
}
std::string cfg_rpcn::generate_npid()

View file

@ -24,7 +24,7 @@ void cfg_upnp::load()
void cfg_upnp::save() const
{
#ifdef _WIN32
const std::string path_to_cfg = fs::get_config_dir() + "config/";
const std::string path_to_cfg = fs::get_config_dir(true);
if (!fs::create_path(path_to_cfg))
{
upnp_cfg_log.error("Could not create path: %s", path_to_cfg);
@ -51,9 +51,5 @@ void cfg_upnp::set_device_url(std::string_view url)
std::string cfg_upnp::get_path()
{
#ifdef _WIN32
return fs::get_config_dir() + "config/upnp.yml";
#else
return fs::get_config_dir() + "upnp.yml";
#endif
return fs::get_config_dir(true) + "upnp.yml";
}

View file

@ -374,7 +374,22 @@ void Emulator::Init()
g_cfg_defaults = g_cfg.to_string();
const std::string cfg_path = fs::get_config_dir() + "/config.yml";
const std::string cfg_path = fs::get_config_dir(true) + "config.yml";
// Move file from deprecated location to new location
#ifdef _WIN32
const std::string old_path = fs::get_config_dir(false) + "config.yml";
if (fs::is_file(old_path))
{
sys_log.notice("Found deprecated config.yml file: '%s'", old_path);
if (!fs::rename(old_path, cfg_path, false))
{
sys_log.error("Failed to move '%s' to '%s' (error='%s')", old_path, cfg_path, fs::g_tls_error);
}
}
#endif
// Save new global config if it doesn't exist or is empty
if (fs::stat_t info{}; !fs::get_stat(cfg_path, info) || info.size == 0)
@ -4466,7 +4481,7 @@ void Emulator::SaveSettings(const std::string& settings, const std::string& titl
if (title_id.empty())
{
config_name = fs::get_config_dir() + "/config.yml";
config_name = fs::get_config_dir(true) + "config.yml";
}
else
{

View file

@ -123,7 +123,7 @@ bool games_config::save_nl()
YAML::Emitter out;
out << m_games;
fs::pending_file temp(fs::get_config_dir() + "/games.yml");
fs::pending_file temp(fs::get_config_dir(true) + "games.yml");
if (temp.file && temp.file.write(out.c_str(), out.size()) >= out.size() && temp.commit())
{
@ -147,7 +147,24 @@ void games_config::load()
m_games.clear();
if (fs::file f{fs::get_config_dir() + "/games.yml", fs::read + fs::create})
const std::string path = fs::get_config_dir(true) + "games.yml";
// Move file from deprecated location to new location
#ifdef _WIN32
const std::string old_path = fs::get_config_dir(false) + "games.yml";
if (fs::is_file(old_path))
{
cfg_log.notice("Found deprecated games.yml file: '%s'", old_path);
if (!fs::rename(old_path, path, false))
{
cfg_log.error("Failed to move '%s' to '%s' (error='%s')", old_path, path, fs::g_tls_error);
}
}
#endif
if (fs::file f{path, fs::read + fs::create})
{
auto [result, error] = yaml_load(f.to_string());

View file

@ -311,11 +311,7 @@ namespace rpcs3::utils
std::string get_custom_config_dir()
{
#ifdef _WIN32
return fs::get_config_dir() + "config/custom_configs/";
#else
return fs::get_config_dir() + "custom_configs/";
#endif
return fs::get_config_dir(true) + "custom_configs/";
}
std::string get_custom_config_path(const std::string& identifier)
@ -330,11 +326,7 @@ namespace rpcs3::utils
std::string get_input_config_root()
{
#ifdef _WIN32
return fs::get_config_dir() + "config/input_configs/";
#else
return fs::get_config_dir() + "input_configs/";
#endif
return fs::get_config_dir(true) + "input_configs/";
}
std::string get_input_config_dir(const std::string& title_id)

View file

@ -115,7 +115,7 @@ void cfg_vfs::load()
void cfg_vfs::save() const
{
#ifdef _WIN32
const std::string path_to_cfg = fs::get_config_dir() + "config/";
const std::string path_to_cfg = fs::get_config_dir(true);
if (!fs::create_path(path_to_cfg))
{
vfs_log.error("Could not create path: %s", path_to_cfg);
@ -140,9 +140,5 @@ void cfg_vfs::save() const
std::string cfg_vfs::get_path()
{
#ifdef _WIN32
return fs::get_config_dir() + "config/vfs.yml";
#else
return fs::get_config_dir() + "vfs.yml";
#endif
return fs::get_config_dir(true) + "vfs.yml";
}