Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
New switch --user-config
osdt:
--- Quote from: dmoore on January 22, 2014, 04:17:00 am ---... which I think is as simple as the following one liner:
--- Code: ---Index: src/sdk/configmanager.cpp
===================================================================
--- src/sdk/configmanager.cpp (revision 9594)
+++ src/sdk/configmanager.cpp (working copy)
@@ -68,10 +71,10 @@
inline wxString GetPortableConfigDir()
{
TCHAR buffer[MAX_PATH];
- if (::GetEnvironmentVariable(_T("APPDATA"), buffer, MAX_PATH))
+ if (!ConfigManager::has_alternate_user_data_path && ::GetEnvironmentVariable(_T("APPDATA"), buffer, MAX_PATH))
return wxString::Format(_T("%s\\CodeBlocks"), buffer);
else
--- End code ---
--- End quote ---
Yes that works also. If you want to keep GetPortableConfigDir() it has to be declared as friend of ConfigManager. But it's not needed anymore if you implement ConfigManager::GetUserDataFolder() like below:
--- Code: ---inline wxString ConfigManager::GetUserDataFolder()
{
if (has_alternate_user_data_path)
return alternate_user_data_path;
#ifdef __WXMSW__
TCHAR buffer[MAX_PATH];
if (::GetEnvironmentVariable(_T("APPDATA"), buffer, MAX_PATH))
return wxString::Format(_T("%s\\CodeBlocks"), buffer);
#endif
return wxStandardPathsBase::Get().GetUserDataDir();
}
--- End code ---
--- Quote from: dmoore on January 22, 2014, 04:17:00 am ---I also forgot to override the check for default.conf in the executable directory (I think it makes sense to obey the switch if it is specified). See the second change in this part of the patch.
--- End quote ---
Good idea.
- osdt
dmoore:
osdt: Good point.
New patch merges the GetPortable_blah_blah code into GetUserDataFolder and gets rid of a bunch of #ifdef's. I haven't yet tested on windows.
osdt:
Good work, the last patch works on Windows too.
--- Quote from: dmoore on January 22, 2014, 04:26:04 am ---One last thing: what if the user specifies a relative path?
--- End quote ---
I would vote for full path only. On Linux ~/xyz could be supported as a bonus. Maybe the other devs want to comment on this.
- osdt
dmoore:
Still looking for feedback on this. It works for me on both Linux and Windows. I would like to commit it next weekend (i.e. Feb 1).
dmoore:
Last chance... committing later today unless I hear objections. ;D
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version