rpcsx/rpcs3/Emu/IPC_config.cpp

67 lines
1.1 KiB
C++
Raw Permalink Normal View History

2022-06-18 21:30:38 +02:00
#include "stdafx.h"
#include "IPC_config.h"
cfg_ipc g_cfg_ipc;
LOG_CHANNEL(IPC);
void cfg_ipc::load()
{
const std::string path = cfg_ipc::get_path();
fs::file cfg_file(path, fs::read);
if (cfg_file)
{
IPC.notice("Loading IPC config. Path: %s", path);
from_string(cfg_file.to_string());
}
else
{
IPC.notice("IPC config missing. Using default settings. Path: %s", path);
from_default();
}
}
void cfg_ipc::save() const
{
#ifdef _WIN32
const std::string path_to_cfg = fs::get_config_dir(true);
2022-06-18 21:30:38 +02:00
if (!fs::create_path(path_to_cfg))
{
IPC.error("Could not create path: %s", path_to_cfg);
}
#endif
2023-12-29 18:33:29 +01:00
const std::string path = cfg_ipc::get_path();
2022-06-18 21:30:38 +02:00
2023-12-29 18:33:29 +01:00
if (!cfg::node::save(path))
2022-06-18 21:30:38 +02:00
{
2023-12-29 18:33:29 +01:00
IPC.error("Could not save config: %s (error=%s)", path, fs::g_tls_error);
2022-06-18 21:30:38 +02:00
}
}
std::string cfg_ipc::get_path()
{
return fs::get_config_dir(true) + "ipc.yml";
2022-06-18 21:30:38 +02:00
}
bool cfg_ipc::get_server_enabled() const
{
return ipc_server_enabled.get();
}
int cfg_ipc::get_port() const
{
return ipc_port;
}
void cfg_ipc::set_server_enabled(const bool enabled)
{
this->ipc_server_enabled.set(enabled);
}
void cfg_ipc::set_port(const int port)
{
this->ipc_port.set(port);
}