From 8208d1541d0005d2e5fe7c5fe663929ec30fb930 Mon Sep 17 00:00:00 2001 From: otavepto <153766569+otavepto@users.noreply.github.com> Date: Sat, 29 Jun 2024 03:53:23 +0300 Subject: [PATCH] crash_printer: use multibyte std::string --- crash_printer/crash_printer/win.hpp | 2 +- crash_printer/tests/test_win.cpp | 2 +- crash_printer/win.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crash_printer/crash_printer/win.hpp b/crash_printer/crash_printer/win.hpp index 18e3ad01..e9c804d4 100644 --- a/crash_printer/crash_printer/win.hpp +++ b/crash_printer/crash_printer/win.hpp @@ -6,7 +6,7 @@ namespace crash_printer { -bool init(const std::wstring &log_file); +bool init(const std::string &log_file); void deinit(); diff --git a/crash_printer/tests/test_win.cpp b/crash_printer/tests/test_win.cpp index 6eca3b6d..0c027a15 100644 --- a/crash_printer/tests/test_win.cpp +++ b/crash_printer/tests/test_win.cpp @@ -8,7 +8,7 @@ #define WIN32_LEAN_AND_MEAN #include -std::wstring logs_filepath = L"./crash_test/zxc.txt"; +std::string logs_filepath = "./crash_test/zxc.txt"; static LONG WINAPI exception_handler(LPEXCEPTION_POINTERS ex_pointers) diff --git a/crash_printer/win.cpp b/crash_printer/win.cpp index 77a4ae93..bff60a54 100644 --- a/crash_printer/win.cpp +++ b/crash_printer/win.cpp @@ -14,7 +14,7 @@ static LPTOP_LEVEL_EXCEPTION_FILTER originalExceptionFilter = nullptr; -static std::wstring logs_filepath{}; +static std::string logs_filepath{}; static void print_stacktrace(std::ofstream &file, CONTEXT* context) { auto this_proc = GetCurrentProcess(); @@ -104,7 +104,7 @@ static void log_exception(LPEXCEPTION_POINTERS ex_pointers) return; } - std::ofstream file(std::filesystem::path(logs_filepath), std::ios::app); + std::ofstream file(std::filesystem::u8path(logs_filepath), std::ios::out | std::ios::app); std::string time(common_helpers::get_utc_time()); common_helpers::write(file, "[" + time + "]"); @@ -133,7 +133,7 @@ static LONG WINAPI exception_handler(LPEXCEPTION_POINTERS ex_pointers) } -bool crash_printer::init(const std::wstring &log_file) +bool crash_printer::init(const std::string &log_file) { logs_filepath = log_file; originalExceptionFilter = SetUnhandledExceptionFilter(exception_handler);