News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

New switch --user-config

Started by dmoore, January 20, 2014, 03:33:58 PM

Previous topic - Next topic

osdt

Quote from: dmoore on January 22, 2014, 04:17:00 AM
... which I think is as simple as the following one liner:

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

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:

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();
}


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.
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.
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

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?

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).
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

dmoore

Last chance... committing later today unless I hear objections.  ;D
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

dmoore

Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]