Skip to content

Commit

Permalink
Config: Ensure conversion to filesystem::path uses utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
derrod authored and tt2468 committed Jun 11, 2024
1 parent 3b7c1c5 commit 9e48274
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ bool MigratePersistentData()
std::error_code ec;

// Ensure module config directory exists
std::string moduleConfigDirectory = Utils::Obs::StringHelper::GetModuleConfigPath("");
auto moduleConfigDirectory = std::filesystem::u8path(Utils::Obs::StringHelper::GetModuleConfigPath(""));
if (!std::filesystem::exists(moduleConfigDirectory, ec))
std::filesystem::create_directories(moduleConfigDirectory, ec);
if (ec) {
Expand All @@ -203,10 +203,11 @@ bool MigratePersistentData()
}

// Move any existing persistent data to module config directory, then delete old file
std::string oldPersistentDataPath =
Utils::Obs::StringHelper::GetCurrentProfilePath() + "/../../../obsWebSocketPersistentData.json";
auto oldPersistentDataPath = std::filesystem::u8path(Utils::Obs::StringHelper::GetCurrentProfilePath() +
"/../../../obsWebSocketPersistentData.json");
if (std::filesystem::exists(oldPersistentDataPath, ec)) {
std::string persistentDataPath = Utils::Obs::StringHelper::GetModuleConfigPath("persistent_data.json");
auto persistentDataPath =
std::filesystem::u8path(Utils::Obs::StringHelper::GetModuleConfigPath("persistent_data.json"));
std::filesystem::copy_file(oldPersistentDataPath, persistentDataPath, ec);
std::filesystem::remove(oldPersistentDataPath, ec);
blog(LOG_INFO, "[MigratePersistentData] Persistent data migrated to new path");
Expand Down

0 comments on commit 9e48274

Please sign in to comment.