+wxConfig *wxConfig::Set(wxConfig *pConfig)
+{
+ wxConfig *pOld = ms_pConfig;
+ ms_pConfig = pConfig;
+ return pOld;
+}
+
+void wxConfig::Create()
+{
+ ms_pConfig = wxTheApp->CreateConfig();
+}
+
+const char *wxConfig::Read(const char *szKey, const char *szDefault) const
+{
+ static char s_szBuf[1024];
+ wxString s;
+ Read(&s, szKey, szDefault);
+ strncpy(s_szBuf, s, WXSIZEOF(s_szBuf));
+
+ return s_szBuf;
+}
+
+// ----------------------------------------------------------------------------
+// Config::PathChanger
+// ----------------------------------------------------------------------------
+
+wxConfig::PathChanger::PathChanger(const wxConfig *pContainer,
+ const wxString& strEntry)
+{
+ m_pContainer = (wxConfig *)pContainer;
+ wxString strPath = strEntry.Before(APPCONF_PATH_SEPARATOR);
+
+ // special case of "/keyname" when there is nothing before "/"
+ if ( strPath.IsEmpty() && strEntry[0] == APPCONF_PATH_SEPARATOR )
+ strPath = APPCONF_PATH_SEPARATOR;
+
+ if ( !strPath.IsEmpty() ) {
+ // do change the path
+ m_bChanged = TRUE;
+ m_strName = strEntry.Right(APPCONF_PATH_SEPARATOR);
+ m_strOldPath = m_pContainer->GetPath();
+ m_strOldPath += APPCONF_PATH_SEPARATOR;
+ m_pContainer->SetPath(strPath);
+ }
+ else {
+ // it's a name only, without path - nothing to do
+ m_bChanged = FALSE;
+ m_strName = strEntry;
+ }
+}
+
+wxConfig::PathChanger::~PathChanger()
+{
+ // only restore path if it was changed
+ if ( m_bChanged ) {
+ m_pContainer->SetPath(m_strOldPath);
+ }
+}
+