From 86de0e760a5c665bcfe2d3b7d016141c279bc61a Mon Sep 17 00:00:00 2001 From: sdottaka Date: Sun, 17 May 2015 22:45:25 +0900 Subject: [PATCH] Allow using environment variables in temporary path name --HG-- branch : stable --- Src/Environment.cpp | 2 +- Src/MainFrm.cpp | 3 +++ Src/Merge.cpp | 15 ++++++++++----- Src/Merge.h | 1 + 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Src/Environment.cpp b/Src/Environment.cpp index 8286a8b08..be294e0c8 100644 --- a/Src/Environment.cpp +++ b/Src/Environment.cpp @@ -27,7 +27,7 @@ static String strProgPath; void env_SetTempPath(const String& path) { - strTempPath = paths_AddTrailingSlash(path); + strTempPath = paths_AddTrailingSlash(paths_GetLongPath(path)); paths_CreateIfNeeded(strTempPath); } diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 1c273eff2..9cf307373 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -837,6 +837,9 @@ void CMainFrame::OnOptions() UpdateResources(); } + // Set new temporary path + theApp.SetupTempPath(); + // Set new filterpath String filterPath = GetOptionsMgr()->GetString(OPT_FILTER_USERPATH); theApp.m_pGlobalFileFilter->SetUserFilterPath(filterPath); diff --git a/Src/Merge.cpp b/Src/Merge.cpp index 4e29ba1f2..adca0f109 100644 --- a/Src/Merge.cpp +++ b/Src/Merge.cpp @@ -288,11 +288,7 @@ BOOL CMergeApp::InitInstance() OptionsInit(); // Implementation in OptionsInit.cpp // Initialize temp folder - String instTemp = env_GetPerInstanceString(TempFolderPrefix); - if (GetOptionsMgr()->GetBool(OPT_USE_SYSTEM_TEMP_PATH)) - env_SetTempPath(paths_ConcatPath(env_GetSystemTempPath(), instTemp)); - else - env_SetTempPath(paths_ConcatPath(GetOptionsMgr()->GetString(OPT_CUSTOM_TEMP_PATH), instTemp)); + SetupTempPath(); // Cleanup left over tempfiles from previous instances. // Normally this should not neet to do anything - but if for some reason @@ -1371,6 +1367,15 @@ void CMergeApp::AddToRecentProjectsMRU(LPCTSTR sPathName) } } +void CMergeApp::SetupTempPath() +{ + String instTemp = env_GetPerInstanceString(TempFolderPrefix); + if (GetOptionsMgr()->GetBool(OPT_USE_SYSTEM_TEMP_PATH)) + env_SetTempPath(paths_ConcatPath(env_GetSystemTempPath(), instTemp)); + else + env_SetTempPath(paths_ConcatPath(GetOptionsMgr()->GetString(OPT_CUSTOM_TEMP_PATH), instTemp)); +} + /** * @brief Handles menu selection from recent projects list * @param [in] nID Menu ID of the selected item diff --git a/Src/Merge.h b/Src/Merge.h index 7c4b18fdd..9ac5e3f2f 100644 --- a/Src/Merge.h +++ b/Src/Merge.h @@ -148,6 +148,7 @@ public: BOOL SyncFileToVCS(const String& pszDest, BOOL &bApplyToAll, String& psError); bool GetMergingMode() const; void SetMergingMode(bool bMergingMode); + void SetupTempPath(); // Implementation protected: -- 2.11.0