MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / InitLogging

Function InitLogging

cppcryptfs/dokan/cryptdokan.cpp:2837–2890  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2835
2836
2837static void InitLogging()
2838{
2839
2840 const WCHAR* logdir = L"C:\\cppcryptfslogs";
2841
2842 if (!PathFileExists(logdir)) {
2843 CString strMsg;
2844 strMsg.Format(LocUtils::GetStringFromResources(IDS_UNABLE_INIT_LOGGING).c_str(), logdir);
2845 ::MessageBox(NULL, strMsg, L"cppcryptfs", MB_OK | MB_ICONEXCLAMATION);
2846 return;
2847 }
2848
2849 auto pad2 = [](int n) {
2850
2851 wchar_t buf[8];
2852
2853 *buf = L'\0';
2854
2855 swprintf_s(buf, L"%02d", n);
2856
2857 return wstring(buf);
2858 };
2859
2860 SYSTEMTIME st;
2861
2862 memset(&st, 0, sizeof(st));
2863
2864 GetLocalTime(&st);
2865
2866 wstring year, month, day, hour, minute, second;
2867
2868 year = to_wstring(st.wYear);
2869 month = pad2(st.wMonth);
2870 day = pad2(st.wDay);
2871
2872 hour = pad2(st.wHour);
2873 minute = pad2(st.wMinute);
2874 second = pad2(st.wSecond);
2875
2876 wstring logname = wstring(logdir) + L"\\cppcryptfs-" + year + L"-" + month + L"-" + day + L"_" + hour + L"." + minute + L"." + second + L".log";
2877
2878 const int result = _wfopen_s(&g_DebugLogFile, logname.c_str(), L"at+");
2879
2880 if (result == 0) {
2881 CString strMsg;
2882 strMsg.Format(LocUtils::GetStringFromResources(IDS_LOGGING_TO_LOGNAME).c_str(), logname);
2883 ::MessageBox(NULL, strMsg, L"cppcryptfs", MB_OK | MB_ICONINFORMATION);
2884 } else {
2885 CString strMsg;
2886 strMsg.Format(LocUtils::GetStringFromResources(IDS_UNABLE_OPEN_LOGNAME).c_str(), logname);
2887 ::MessageBox(NULL, strMsg, L"cppcryptfs", MB_OK | MB_ICONERROR);
2888 }
2889
2890}
2891
2892void crypt_at_start()
2893{

Callers 1

crypt_at_startFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected