Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/utils/Json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ json Utils::Json::ObsDataToJson(obs_data_t *d, bool includeDefault)

bool Utils::Json::GetJsonFileContent(std::string fileName, json &content)
{
std::ifstream f(fileName);
std::ifstream f(std::filesystem::u8path(fileName));
if (!f.is_open())
return false;

Expand All @@ -195,9 +195,11 @@ bool Utils::Json::GetJsonFileContent(std::string fileName, json &content)

bool Utils::Json::SetJsonFileContent(std::string fileName, const json &content, bool makeDirs)
{
auto jsonFilePath = std::filesystem::u8path(fileName);

if (makeDirs) {
auto p = jsonFilePath.parent_path();
std::error_code ec;
auto p = std::filesystem::path(fileName).parent_path();
if (!ec && !std::filesystem::exists(p, ec))
std::filesystem::create_directories(p, ec);
if (ec) {
Expand All @@ -207,7 +209,7 @@ bool Utils::Json::SetJsonFileContent(std::string fileName, const json &content,
}
}

std::ofstream f(fileName);
std::ofstream f(jsonFilePath);
if (!f.is_open()) {
blog(LOG_ERROR, "[Utils::Json::SetJsonFileContent] Failed to open file `%s` for writing", fileName.c_str());
return false;
Expand Down