mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Dont write directly to files but rather write and copy a tmp file
This commit is contained in:
parent
c8930850e3
commit
d718b0b34e
9 changed files with 101 additions and 69 deletions
|
@ -105,13 +105,11 @@ bool deleteEntry (ServerListSpec server)
|
|||
}
|
||||
|
||||
std::string path = ServerList::getFilePath();
|
||||
std::ofstream stream (path.c_str());
|
||||
if (stream.is_open())
|
||||
{
|
||||
stream<<ServerList::serialize(serverlist);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
std::ostringstream ss(std::ios_base::binary);
|
||||
ss << ServerList::serialize(serverlist);
|
||||
if (!fs::safeWriteToFile(path, ss.str()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -128,11 +126,9 @@ bool insert (ServerListSpec server)
|
|||
serverlist.insert(serverlist.begin(), server);
|
||||
|
||||
std::string path = ServerList::getFilePath();
|
||||
std::ofstream stream (path.c_str());
|
||||
if (stream.is_open())
|
||||
{
|
||||
stream<<ServerList::serialize(serverlist);
|
||||
}
|
||||
std::ostringstream ss(std::ios_base::binary);
|
||||
ss << ServerList::serialize(serverlist);
|
||||
fs::safeWriteToFile(path, ss.str());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue