Added backing up previous logfile

This commit is contained in:
2021-12-10 03:24:43 +03:00
parent b8d3db9289
commit 5137eed759
2 changed files with 12 additions and 6 deletions

View File

@@ -37,6 +37,11 @@ void OpenLogFile() {
fs::path log_path = lpszPath; fs::path log_path = lpszPath;
log_path.replace_extension(L".log"); log_path.replace_extension(L".log");
std::wstring logname = log_path.stem() += L".log"; std::wstring logname = log_path.stem() += L".log";
std::wstring backupname = log_path.stem() += L".bak";
if (fs::exists(logname)) {
fs::rename(logname, backupname);
}
logfile.open(logname); logfile.open(logname);
if (logfile.is_open()) { if (logfile.is_open()) {

View File

@@ -67,7 +67,7 @@ VOID MoveWindowToMonitorCenter(HWND hwnd, BOOL bWorkArea, BOOL bResize)
LONG nWidth = fgwrc.right - fgwrc.left; LONG nWidth = fgwrc.right - fgwrc.left;
LONG nHeight = fgwrc.bottom - fgwrc.top; LONG nHeight = fgwrc.bottom - fgwrc.top;
diag_log(L"Moving window from x =", fgwrc.left, L" y =", fgwrc.top, L" r =", fgwrc.right, L" b =", fgwrc.bottom); diag_log(L"Moving window from x =", fgwrc.left, L"y =", fgwrc.top);
MONITORINFO mi; MONITORINFO mi;
mi.cbSize = sizeof(MONITORINFO); mi.cbSize = sizeof(MONITORINFO);
@@ -101,7 +101,8 @@ VOID MoveWindowToMonitorCenter(HWND hwnd, BOOL bWorkArea, BOOL bResize)
MoveWindow(hwnd, x, y, nWidth, nHeight, TRUE); MoveWindow(hwnd, x, y, nWidth, nHeight, TRUE);
SendMessage(hwnd, WM_EXITSIZEMOVE, NULL, NULL); SendMessage(hwnd, WM_EXITSIZEMOVE, NULL, NULL);
diag_log(L"Moving window to x =", x, L" y =", y, L" r =", aw, L" b =", ah); diag_log(L"Moving window to x =", x, L"y =", y);
diag_log(L"Quiting MoveWindowToMonitorCenter()");
} }
@@ -112,7 +113,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm
UNREFERENCED_PARAMETER(lpCmdLine); UNREFERENCED_PARAMETER(lpCmdLine);
OpenLogFile(); OpenLogFile();
diag_log(L"Entering WinMain()..."); diag_log(L"Entering WinMain()");
hInst = hInstance; hInst = hInstance;
@@ -136,7 +137,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm
int nArgs = 0; int nArgs = 0;
LPWSTR* szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); LPWSTR* szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
diag_log(L"nArgs =", nArgs, L" Args: ", *szArglist); diag_log(L"nArgs =", nArgs, L", Args: ", *szArglist);
(nArgs >= 2 && 0 == lstrcmpiW(szArglist[1], TEXT("/hide"))) ? bShowIcon = FALSE : bShowIcon = TRUE; (nArgs >= 2 && 0 == lstrcmpiW(szArglist[1], TEXT("/hide"))) ? bShowIcon = FALSE : bShowIcon = TRUE;
LocalFree(szArglist); LocalFree(szArglist);
@@ -400,7 +401,7 @@ BOOL CheckWindow(HWND hFW)
VOID HandlingTrayIcon() VOID HandlingTrayIcon()
{ {
diag_log(L"Entering HandlingTrayIcon()...", L" bShowIcon=", bShowIcon); diag_log(L"Entering HandlingTrayIcon(). bShowIcon =", bShowIcon);
if (bShowIcon) if (bShowIcon)
{ {
if (!Shell_NotifyIcon(NIM_ADD, &nid)) if (!Shell_NotifyIcon(NIM_ADD, &nid))
@@ -414,7 +415,7 @@ VOID HandlingTrayIcon()
{ {
Shell_NotifyIcon(NIM_DELETE, &nid); Shell_NotifyIcon(NIM_DELETE, &nid);
} }
diag_log(L"Quiting HandlingTrayIcon()..."); diag_log(L"Quiting HandlingTrayIcon()");
} }
VOID ShowError(UINT uID) VOID ShowError(UINT uID)