mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
configuration: Fix failed saving due to invalid path
This commit is contained in:
parent
04e52d143f
commit
a9da1481d7
2 changed files with 3 additions and 7 deletions
|
@ -33,8 +33,7 @@ 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",
|
if (!obs_data_save_json_safe(_data.get(), _config_path.string().c_str(), ".tmp", path_backup_ext.data())) {
|
||||||
_config_backup_path.string().c_str())) {
|
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
@ -42,20 +41,18 @@ streamfx::configuration::~configuration()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
streamfx::configuration::configuration() : _data(), _config_path(), _config_backup_path()
|
streamfx::configuration::configuration() : _data(), _config_path()
|
||||||
{
|
{
|
||||||
{ // Retrieve global configuration path.
|
{ // Retrieve global configuration path.
|
||||||
const char* path = obs_module_config_path("config.json");
|
const char* path = obs_module_config_path("config.json");
|
||||||
_config_path = path;
|
_config_path = path;
|
||||||
_config_backup_path = std::filesystem::path(_config_path).concat(path_backup_ext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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::exception();
|
throw std::exception();
|
||||||
} else {
|
} else {
|
||||||
obs_data_t* data = obs_data_create_from_json_file_safe(_config_path.string().c_str(),
|
obs_data_t* data = obs_data_create_from_json_file_safe(_config_path.string().c_str(), path_backup_ext.data());
|
||||||
_config_backup_path.string().c_str());
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,7 +27,6 @@ namespace streamfx {
|
||||||
std::shared_ptr<obs_data_t> _data;
|
std::shared_ptr<obs_data_t> _data;
|
||||||
|
|
||||||
std::filesystem::path _config_path;
|
std::filesystem::path _config_path;
|
||||||
std::filesystem::path _config_backup_path;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~configuration();
|
~configuration();
|
||||||
|
|
Loading…
Reference in a new issue