MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / SaveSettings

Method SaveSettings

rpcs3/Emu/System.cpp:4532–4576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4530}
4531
4532void Emulator::SaveSettings(const std::string& settings, const std::string& title_id)
4533{
4534 std::string config_name;
4535
4536 if (title_id.empty())
4537 {
4538 config_name = fs::get_config_dir(true) + "config.yml";
4539 }
4540 else
4541 {
4542 config_name = rpcs3::utils::get_custom_config_path(title_id);
4543 }
4544
4545 // Save config atomically
4546 fs::pending_file temp(config_name);
4547 if (!temp.file)
4548 {
4549 sys_log.error("Could not save config to %s (failed to create temporary file) (error=%s)", config_name, fs::g_tls_error);
4550 }
4551 else
4552 {
4553 temp.file.write(settings.c_str(), settings.size());
4554 if (!temp.commit())
4555 {
4556 sys_log.error("Could not save config to %s (failed to commit) (error=%s)", config_name, fs::g_tls_error);
4557 }
4558 }
4559
4560 // Check if the running config/title is the same as the edited config/title.
4561 if (config_name == g_cfg.name || title_id == Emu.GetTitleID())
4562 {
4563 // Update current config
4564 if (!g_cfg.from_string({settings.c_str(), settings.size()}, !Emu.IsStopped()))
4565 {
4566 sys_log.fatal("Failed to update configuration");
4567 }
4568 else if (!Emu.IsStopped()) // Don't spam the log while emulation is stopped. The config will be logged on boot anyway.
4569 {
4570 sys_log.notice("Updated configuration:\n%s\n", g_cfg.to_string());
4571 }
4572 }
4573
4574 // Backup config
4575 g_backup_cfg.from_string(g_cfg.to_string());
4576}
4577
4578Emulator Emu;

Callers

nothing calls this directly

Calls 10

get_custom_config_pathFunction · 0.85
errorMethod · 0.80
c_strMethod · 0.80
commitMethod · 0.80
IsStoppedMethod · 0.80
emptyMethod · 0.45
writeMethod · 0.45
sizeMethod · 0.45
from_stringMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected