Changed: When writing to icfg or keys files, write to temp file and then rename
This commit is contained in:
parent
6b75bdb0e1
commit
8b767cabcd
1 changed files with 7 additions and 7 deletions
|
@ -1826,7 +1826,8 @@ bool CInterfaceManager::saveConfig (const string &filename)
|
||||||
|
|
||||||
COFile f;
|
COFile f;
|
||||||
|
|
||||||
if (!f.open(filename)) return false;
|
// using temporary file, so no f.close() unless its a success
|
||||||
|
if (!f.open(filename, false, false, true)) return false;
|
||||||
|
|
||||||
CInterfaceConfig ic;
|
CInterfaceConfig ic;
|
||||||
|
|
||||||
|
@ -1873,7 +1874,6 @@ bool CInterfaceManager::saveConfig (const string &filename)
|
||||||
{
|
{
|
||||||
nlwarning("Config saving failed");
|
nlwarning("Config saving failed");
|
||||||
// couldn't save result so do not continue
|
// couldn't save result so do not continue
|
||||||
f.close();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1929,14 +1929,14 @@ bool CInterfaceManager::saveConfig (const string &filename)
|
||||||
nlwarning("Bad user dyn chat saving");
|
nlwarning("Bad user dyn chat saving");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f.close();
|
||||||
}
|
}
|
||||||
catch(const NLMISC::EStream &)
|
catch(const NLMISC::EStream &)
|
||||||
{
|
{
|
||||||
f.close();
|
|
||||||
nlwarning("Config saving failed.");
|
nlwarning("Config saving failed.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
f.close();
|
|
||||||
|
|
||||||
ContinentMngr.serialFOWMaps();
|
ContinentMngr.serialFOWMaps();
|
||||||
|
|
||||||
|
@ -2645,7 +2645,8 @@ bool CInterfaceManager::saveKeys(const std::string &filename)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
COFile file;
|
COFile file;
|
||||||
if (file.open (filename))
|
// using temporary file, so no file.close() unless its a success
|
||||||
|
if (file.open (filename, false, false, true))
|
||||||
{
|
{
|
||||||
COXml xmlStream;
|
COXml xmlStream;
|
||||||
xmlStream.init (&file);
|
xmlStream.init (&file);
|
||||||
|
@ -2675,8 +2676,7 @@ bool CInterfaceManager::saveKeys(const std::string &filename)
|
||||||
}
|
}
|
||||||
catch (const Exception &e)
|
catch (const Exception &e)
|
||||||
{
|
{
|
||||||
nlwarning ("Error while writing the file %s : %s. Remove it.", filename.c_str(), e.what ());
|
nlwarning ("Error while writing the file %s : %s.", filename.c_str(), e.what ());
|
||||||
CFile::deleteFile(filename);
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue