diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2017-03-07 01:37:08 +0300 |
---|---|---|
committer | Kacper Michajłow <kasper93@gmail.com> | 2017-03-07 01:40:14 +0300 |
commit | e95538afb865064bb4ae157200dace1c8fc47f8d (patch) | |
tree | fd3fce307b02686e891792a672a80fab9d83c916 | |
parent | e7620faab630323461a16804473f8608eb6cb4f4 (diff) |
Logger: Create output directory if doesn't exist.
Fixes #6037
-rw-r--r-- | src/mpc-hc/Logger.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mpc-hc/Logger.h b/src/mpc-hc/Logger.h index 9903b2bf0..448de65f0 100644 --- a/src/mpc-hc/Logger.h +++ b/src/mpc-hc/Logger.h @@ -1,5 +1,5 @@ /* - * (C) 2015-2016 see Authors.txt + * (C) 2015-2017 see Authors.txt * * This file is part of MPC-HC. * @@ -78,8 +78,14 @@ private: // Check if logging is enabled only during initialization to avoid incomplete logs ASSERT(s.IsInitialized()); CString savePath; - VERIFY(AfxGetMyApp()->GetAppSavePath(savePath)); - m_file = s.bEnableLogging ? _tfsopen(PathUtils::CombinePaths(savePath, GetFileName<TARGET>()), _T("at"), SH_DENYWR) : nullptr; + if (s.bEnableLogging && AfxGetMyApp()->GetAppSavePath(savePath)) { + if (!PathUtils::Exists(savePath)) { + ::CreateDirectory(savePath, nullptr); + } + m_file = _tfsopen(PathUtils::CombinePaths(savePath, GetFileName<TARGET>()), _T("at"), SH_DENYWR); + } else { + m_file = nullptr; + } ASSERT(!s.bEnableLogging || m_file); } |