diff --git a/source/configuration.cpp b/source/configuration.cpp index 7667c0d2..6bcd8e39 100644 --- a/source/configuration.cpp +++ b/source/configuration.cpp @@ -33,28 +33,25 @@ streamfx::configuration::~configuration() if (_config_path.has_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(); } - } catch (...) { - DLOG_ERROR("Failed to save configuration, next start will be using defaults or backed up configuration."); + } catch (std::exception const& ex) { + DLOG_ERROR("Failed to save configuration: %s", ex.what()); } } streamfx::configuration::configuration() : _data(), _config_path() { - { // Retrieve global configuration path. - char* path = obs_module_config_path("config.json"); - _config_path = path; - bfree(path); - } + // Retrieve global configuration path. + _config_path = streamfx::config_file_path("config.json"); try { if (!std::filesystem::exists(_config_path) || !std::filesystem::is_regular_file(_config_path)) { throw std::runtime_error("Configuration does not exist."); } else { 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) { throw std::runtime_error("Failed to load configuration from disk."); } else {