From 786dc6b08fc0ae85b11276201f28c841b6f109c4 Mon Sep 17 00:00:00 2001
From: Benau <Benau@users.noreply.github.com>
Date: Fri, 8 Oct 2021 15:49:53 +0800
Subject: [PATCH] Fix broken recording saving with unicode path in windows

---
 src/graphics/irr_driver.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp
index ec6fa2d6f..b470290f5 100644
--- a/src/graphics/irr_driver.cpp
+++ b/src/graphics/irr_driver.cpp
@@ -79,6 +79,7 @@
 #include "tracks/track_manager.hpp"
 #include "tracks/track.hpp"
 #include "utils/constants.hpp"
+#include "utils/file_utils.hpp"
 #include "utils/log.hpp"
 #include "utils/profiler.hpp"
 #include "utils/string_utils.hpp"
@@ -2197,8 +2198,10 @@ void IrrDriver::setRecording(bool val)
             timeInfo->tm_year + 1900, timeInfo->tm_mon + 1,
             timeInfo->tm_mday, timeInfo->tm_hour,
             timeInfo->tm_min, timeInfo->tm_sec);
-        ogrSetSavedName((file_manager->getScreenshotDir() +
-            track_name + "_" + time_buffer).c_str());
+        std::string portable_path = FileUtils::getPortableWritingPath(
+            file_manager->getScreenshotDir());
+        ogrSetSavedName(
+            (portable_path + track_name + "_" + time_buffer).c_str());
         ogrPrepareCapture();
     }
     else