The ConfigDialog saves it's ConfigFile itself, but I had a situation where I needed to save a ConfigFile also, so I wrote a generic utility method for saving any ConfigFile. I'll share it here to make it easy to include, or for others to use before it's included :
Code: Select all
/** Saves the given ConfigFile to a file with the given path/name. */
static void saveConfig(Ogre::ConfigFile& config, std::string filename) {
std::fstream fout(filename.c_str(), std::ios::out);
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = config.getSectionIterator();
while (seci.hasMoreElements())
{
Ogre::String sectionName = seci.peekNextKey();
if (sectionName.length() > 0)
fout << '\n' << '[' << seci.peekNextKey() << ']' << '\n';
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
fout << i->first.c_str() << '=' << i->second.c_str() << '\n';
}
}
}