mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-25 04:45:12 +00:00
parent
a666e01506
commit
007974da54
1 changed files with 6 additions and 9 deletions
|
@ -33,28 +33,25 @@ streamfx::configuration::~configuration()
|
||||||
if (_config_path.has_parent_path()) {
|
if (_config_path.has_parent_path()) {
|
||||||
std::filesystem::create_directories(_config_path.parent_path());
|
std::filesystem::create_directories(_config_path.parent_path());
|
||||||
}
|
}
|
||||||
if (!obs_data_save_json_safe(_data.get(), _config_path.string().c_str(), ".tmp", path_backup_ext.data())) {
|
if (!obs_data_save_json_safe(_data.get(), _config_path.u8string().c_str(), ".tmp", path_backup_ext.data())) {
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (std::exception const& ex) {
|
||||||
DLOG_ERROR("Failed to save configuration, next start will be using defaults or backed up configuration.");
|
DLOG_ERROR("Failed to save configuration: %s", ex.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
streamfx::configuration::configuration() : _data(), _config_path()
|
streamfx::configuration::configuration() : _data(), _config_path()
|
||||||
{
|
{
|
||||||
{ // Retrieve global configuration path.
|
// Retrieve global configuration path.
|
||||||
char* path = obs_module_config_path("config.json");
|
_config_path = streamfx::config_file_path("config.json");
|
||||||
_config_path = path;
|
|
||||||
bfree(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!std::filesystem::exists(_config_path) || !std::filesystem::is_regular_file(_config_path)) {
|
if (!std::filesystem::exists(_config_path) || !std::filesystem::is_regular_file(_config_path)) {
|
||||||
throw std::runtime_error("Configuration does not exist.");
|
throw std::runtime_error("Configuration does not exist.");
|
||||||
} else {
|
} else {
|
||||||
obs_data_t* data =
|
obs_data_t* data =
|
||||||
obs_data_create_from_json_file_safe(_config_path.string().c_str(), path_backup_ext.data());
|
obs_data_create_from_json_file_safe(_config_path.u8string().c_str(), path_backup_ext.data());
|
||||||
if (!data) {
|
if (!data) {
|
||||||
throw std::runtime_error("Failed to load configuration from disk.");
|
throw std::runtime_error("Failed to load configuration from disk.");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue