+ if ( !file.Write(filetext, *m_conv) )
+ {
+ wxLogError(_("can't write user configuration file."));
+ return false;
+ }
+
+ if ( !file.Commit() )
+ {
+ wxLogError(_("Failed to update user configuration file."));
+
+ return false;
+ }
+
+ ResetDirty();
+
+#if defined( __WXOSX_MAC__ ) && wxOSX_USE_CARBON
+ m_fnLocalFile.MacSetTypeAndCreator('TEXT', 'ttxt');
+#endif // __WXMAC__
+
+ return true;
+}
+
+#if wxUSE_STREAMS
+
+bool wxFileConfig::Save(wxOutputStream& os, const wxMBConv& conv)
+{
+ // save unconditionally, even if not dirty
+ for ( wxFileConfigLineList *p = m_linesHead; p != NULL; p = p->Next() )
+ {
+ wxString line = p->Text();
+ line += wxTextFile::GetEOL();
+
+ wxCharBuffer buf(line.mb_str(conv));
+ if ( !os.Write(buf, strlen(buf)) )
+ {
+ wxLogError(_("Error saving user configuration data."));
+
+ return false;
+ }
+ }
+
+ ResetDirty();
+
+ return true;
+}
+
+#endif // wxUSE_STREAMS
+
+// ----------------------------------------------------------------------------
+// renaming groups/entries
+// ----------------------------------------------------------------------------
+
+bool wxFileConfig::RenameEntry(const wxString& oldName,
+ const wxString& newName)
+{
+ wxASSERT_MSG( oldName.find(wxCONFIG_PATH_SEPARATOR) == wxString::npos,
+ wxT("RenameEntry(): paths are not supported") );
+
+ // check that the entry exists
+ wxFileConfigEntry *oldEntry = m_pCurrentGroup->FindEntry(oldName);
+ if ( !oldEntry )
+ return false;
+
+ // check that the new entry doesn't already exist
+ if ( m_pCurrentGroup->FindEntry(newName) )
+ return false;
+
+ // delete the old entry, create the new one
+ wxString value = oldEntry->Value();
+ if ( !m_pCurrentGroup->DeleteEntry(oldName) )
+ return false;
+
+ SetDirty();
+
+ wxFileConfigEntry *newEntry = m_pCurrentGroup->AddEntry(newName);
+ newEntry->SetValue(value);
+
+ return true;
+}
+
+bool wxFileConfig::RenameGroup(const wxString& oldName,
+ const wxString& newName)
+{
+ // check that the group exists
+ wxFileConfigGroup *group = m_pCurrentGroup->FindSubgroup(oldName);
+ if ( !group )
+ return false;
+
+ // check that the new group doesn't already exist
+ if ( m_pCurrentGroup->FindSubgroup(newName) )
+ return false;
+
+ group->Rename(newName);
+
+ SetDirty();
+
+ return true;