Patch #1783 2006-12-31 23:11

stahta01

GetConfigFolder patch to make it work in a Portable win32
Download
1783-GetConfigFolde.patch (2.1 KB)
Category
Application::Refinement
Status
Closed
Close date
2007-02-19 03:53
Assigned to
 
Index: src/sdk/configmanager.h
===================================================================
--- src/sdk/configmanager.h    (revision 3444)
+++ src/sdk/configmanager.h    (working copy)
@@ -151,7 +151,7 @@
     * NEVER harcode a path like "C:\CodeBlocks\share\data". Always use one of the following functions to compose a path.
     */
     static wxString GetHomeFolder() { return home_folder; }
-    static wxString GetConfigFolder(){ return config_folder; }
+    static wxString GetConfigFolder(){ return relo ? app_path : config_folder; }
     static wxString GetPluginsFolder(bool global = true){ return GetFolder(global ? sdPluginsGlobal : sdPluginsUser); }
     static wxString GetScriptsFolder(bool global = true){ return GetFolder(global ? sdScriptsGlobal : sdScriptsUser); }
     static wxString GetDataFolder(bool global = true){ return global ? data_path_global : data_path_user; }
Index: src/sdk/configmanager.cpp
===================================================================
--- src/sdk/configmanager.cpp    (revision 3450)
+++ src/sdk/configmanager.cpp    (working copy)
@@ -168,12 +168,17 @@
         SwitchToR(personality);
         return;
     }
+    if (personality == _T("portable"))
+        ConfigManager::relo = true;    
 
     cfg = FindConfigFile(personality + _T(".conf"));
 
     if(cfg.IsEmpty())
     {
-        cfg = wxStandardPathsBase::Get().GetUserDataDir() + wxFILE_SEP_PATH + personality + _T(".conf");
+        if (ConfigManager::relo == true)
+            cfg = ::DetermineExecutablePath() + wxFILE_SEP_PATH + personality + _T(".conf");
+        else    
+            cfg = wxStandardPathsBase::Get().GetUserDataDir() + wxFILE_SEP_PATH + personality + _T(".conf");
         doc = new TiXmlDocument();
         doc->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
         doc->InsertEndChild(TiXmlElement("CodeBlocksConfig"));
@@ -192,7 +197,7 @@
     wxString u(wxStandardPathsBase::Get().GetUserDataDir() + wxFILE_SEP_PATH + filename);
     wxString e(::DetermineExecutablePath() + wxFILE_SEP_PATH +filename);
 
-    if(::wxFileExists(u))
+    if((::wxFileExists(u)) && (ConfigManager::relo == false))
     {
         return u;
     }
stahta01 2006-12-31 23:14

As discussed in thread http://forums.codeblocks.org/index.php?topic=4475 the idea is to get Code::Blocks to work on a USB memory stick. This patch helps that idea progress on. The method GetConfigFolder did not like NOT using %APPDATA%\codeblocks for the plugin Keybinder and other plugins, this patch fixes that. Tim S

stahta01 2007-01-02 09:12

How it works: The method CfgMgrBldr::CfgMgrBldr() calls CfgMgrBldr::FindConfigFile that sets ConfigManager::relo to true if personality + _T(".conf") file is found in ExecutablePath and not in GetUserDataDir. Tim S

killerbot 2007-01-02 11:10

will this be suficient ?? since CfgMgrBldr::FindConfigFile() first checks ifthe config file exists in the user dir, if so it returns, and that relo can not be set to true.

So I am wondering if I want to run the CB on my usb key and my default.conf is next to the exe on my key, and I hav plugged-in my key on a system thathas CB installed, it won't run with my default.conf ??

stahta01 2007-01-02 14:40

I am working on an update to address the sufficient question by having user pass --personality=portable.conf to codeblocks.exe. Tim S

stahta01 2007-01-02 16:13

Added special operational when --personality=portable is passed to codeblocks.exe. Sets ConfigManager::relo = true which makes/uses ::DetermineExecutablePath() + wxFILE_SEP_PATH + _T("portable.conf") as configuration file and uses ::DetermineExecutablePath() as GetConfigFolder. Tim S

stahta01 2007-02-07 23:59

Sounds like this patch does NOT meet the design goals, so just close it.

Tim S