From 01eb9075b46733804b1e987e70edf882ea6b93f3 Mon Sep 17 00:00:00 2001 From: dreamforceinc Date: Sun, 19 Dec 2021 06:23:32 +0300 Subject: [PATCH] Fixed a bug when the log file was not created in the program's folder when launched from the scheduler. --- wCenterWindow/Logger.cpp | 14 ++++++-------- wCenterWindow/wCenterWindow.vcxproj | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/wCenterWindow/Logger.cpp b/wCenterWindow/Logger.cpp index 314e3f2..358981e 100644 --- a/wCenterWindow/Logger.cpp +++ b/wCenterWindow/Logger.cpp @@ -36,18 +36,16 @@ void OpenLogFile() { fs::path log_path = lpszPath; log_path.replace_extension(L".log"); - std::wstring logname = log_path.stem() += L".log"; - std::wstring backupname = log_path.stem() += L".bak"; + fs::path bak_path = log_path; + bak_path.replace_extension(L".bak"); - if (fs::exists(logname)) { - fs::rename(logname, backupname); - } + if (fs::exists(log_path)) fs::rename(log_path, bak_path); - logfile.open(logname); + logfile.open(log_path); if (logfile.is_open()) { diag_log(L"Starting logging."); - diag_log(L"logfile:", logname); - diag_log(logname, L"successfully opened."); + diag_log(L"logfile:", log_path); + diag_log(log_path, L"successfully opened."); } else { MessageBoxW(NULL, L"Can't open logfile! Working without logging.", L"WARNING", MB_OK | MB_ICONWARNING); } diff --git a/wCenterWindow/wCenterWindow.vcxproj b/wCenterWindow/wCenterWindow.vcxproj index d356576..0897fe9 100644 --- a/wCenterWindow/wCenterWindow.vcxproj +++ b/wCenterWindow/wCenterWindow.vcxproj @@ -36,7 +36,7 @@ Application false - v141_xp + v143 true Unicode