Author Topic: New switch --user-config  (Read 14027 times)

Offline osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: New switch --user-config
« Reply #15 on: January 22, 2014, 06:39:47 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

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

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

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: New switch --user-config
« Reply #16 on: January 22, 2014, 03:20:23 pm »
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.

Offline osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: New switch --user-config
« Reply #17 on: January 22, 2014, 11:56:28 pm »
Good work, the last patch works on Windows too.

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

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: New switch --user-config
« Reply #18 on: January 25, 2014, 08:56:16 pm »
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).

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: New switch --user-config
« Reply #19 on: February 01, 2014, 08:26:58 pm »
Last chance... committing later today unless I hear objections.  ;D

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: New switch --user-config
« Reply #20 on: February 02, 2014, 01:43:38 am »
committed rev 9622