Update of /cvsroot/mahogany/M/src/classes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2302/src/classes
Modified Files:
ConfigSource.cpp
Log Message:
added UseFile/GetFilePath()
Index: ConfigSource.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/ConfigSource.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -b -u -2 -r1.17 -r1.18
--- ConfigSource.cpp 5 Jul 2005 12:34:13 -0000 1.17
+++ ConfigSource.cpp 5 Jul 2005 21:23:08 -0000 1.18
@@ -82,8 +82,4 @@
extern const MOption MP_CONFIG_SOURCE_TYPE;
-#ifdef OS_WIN
-extern const MOption MP_USE_CONFIG_FILE;
-#endif // OS_WIN
-
// ----------------------------------------------------------------------------
// globals
@@ -501,7 +497,6 @@
if ( rc )
{
- String key(M_PROFILE_CONFIG_SECTION);
- key << _T('/') << GetOptionName(MP_USE_CONFIG_FILE);
- if ( m_config->Read(key, &localFilePath) )
+ localFilePath = GetFilePath(m_config);
+ if ( !localFilePath.empty() )
{
// we want to use wxFileConfig finally...
@@ -510,5 +505,9 @@
rc = false;
}
- //else: do use wxRegConfig created above
+ else // do use wxRegConfig created above
+ {
+ // as for wxFileConfig, see comment in InitFile()
+ m_config->SetExpandEnvVars(false);
+ }
}
}
@@ -559,9 +558,10 @@
#ifdef OS_WIN
-bool ConfigSourceLocal::InitRegistry()
+/* static */
+wxConfigBase *ConfigSourceLocal::DoCreateRegConfig()
{
// don't give explicit name, but rather use the default logic (it's
// perfectly ok, for the registry case our keys are under vendor\appname)
- wxRegConfig *regconf = new wxRegConfig
+ return new wxRegConfig
(
M_APPLICATIONNAME,
@@ -572,7 +572,12 @@
wxCONFIG_USE_GLOBAL_FILE
);
+}
+
+bool ConfigSourceLocal::InitRegistry()
+{
+ wxConfigBase *regconf = DoCreateRegConfig();
- // see comment in CreateFileConfig()
- regconf->SetExpandEnvVars(false);
+ // don't call SetExpandEnvVars() here: this allows to use env vars in config
+ // file value
DoInit(regconf);
@@ -581,4 +586,33 @@
}
+/* static */
+String ConfigSourceLocal::GetFilePath(wxConfigBase *config)
+{
+ String path;
+ config->Read(GetConfigFileKey(), &path);
+ return path;
+}
+
+/* static */
+void ConfigSourceLocal::UseFile(const String& filename)
+{
+ wxConfigBase *config = DoCreateRegConfig();
+ if ( filename.empty() )
+ config->DeleteEntry(GetConfigFileKey());
+ else
+ config->Write(GetConfigFileKey(), filename);
+ delete config;
+}
+
+/* static */
+String ConfigSourceLocal::GetFilePath()
+{
+ wxConfigBase *config = DoCreateRegConfig();
+ String path = GetFilePath(config);
+ delete config;
+
+ return path;
+}
+
#endif // OS_WIN
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates