mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-18 03:22:35 +00:00
Use raw file IO instead of buffered when saving
This commit is contained in:
parent
723546a56b
commit
ed2036432b
2 changed files with 11 additions and 17 deletions
|
|
@ -294,17 +294,14 @@ void srb2::save_ng_gamedata()
|
|||
{
|
||||
std::string tmpsavepathstring = tmpsavepath.string();
|
||||
srb2::io::FileStream file {tmpsavepathstring, srb2::io::FileStreamMode::kWrite};
|
||||
srb2::io::BufferedOutputStream<srb2::io::FileStream> bos {std::move(file)};
|
||||
|
||||
// The header is necessary to validate during loading.
|
||||
srb2::io::write(static_cast<uint32_t>(GD_VERSION_MAJOR), bos); // major
|
||||
srb2::io::write(static_cast<uint8_t>(GD_VERSION_MINOR), bos); // minor/flags
|
||||
srb2::io::write(static_cast<uint8_t>(gamedata->evercrashed), bos); // dirty (crash recovery)
|
||||
srb2::io::write(static_cast<uint32_t>(GD_VERSION_MAJOR), file); // major
|
||||
srb2::io::write(static_cast<uint8_t>(GD_VERSION_MINOR), file); // minor/flags
|
||||
srb2::io::write(static_cast<uint8_t>(gamedata->evercrashed), file); // dirty (crash recovery)
|
||||
|
||||
std::vector<uint8_t> ubjson = json::to_ubjson(ng);
|
||||
srb2::io::write_exact(bos, tcb::as_bytes(tcb::make_span(ubjson)));
|
||||
bos.flush();
|
||||
file = bos.stream();
|
||||
srb2::io::write_exact(file, tcb::as_bytes(tcb::make_span(ubjson)));
|
||||
file.close();
|
||||
}
|
||||
catch (const srb2::io::FileStreamException& ex)
|
||||
|
|
|
|||
|
|
@ -320,17 +320,14 @@ void PR_SaveProfiles(void)
|
|||
try
|
||||
{
|
||||
io::FileStream file {tmppath, io::FileStreamMode::kWrite};
|
||||
io::BufferedOutputStream<io::FileStream> bos {std::move(file)};
|
||||
|
||||
io::write(static_cast<uint32_t>(0x52494E47), bos, io::Endian::kBE); // "RING"
|
||||
io::write(static_cast<uint32_t>(0x5052464C), bos, io::Endian::kBE); // "PRFL"
|
||||
io::write(static_cast<uint8_t>(0), bos); // reserved1
|
||||
io::write(static_cast<uint8_t>(0), bos); // reserved2
|
||||
io::write(static_cast<uint8_t>(0), bos); // reserved3
|
||||
io::write(static_cast<uint8_t>(0), bos); // reserved4
|
||||
io::write_exact(bos, tcb::as_bytes(tcb::make_span(ubjson)));
|
||||
bos.flush();
|
||||
file = bos.stream();
|
||||
io::write(static_cast<uint32_t>(0x52494E47), file, io::Endian::kBE); // "RING"
|
||||
io::write(static_cast<uint32_t>(0x5052464C), file, io::Endian::kBE); // "PRFL"
|
||||
io::write(static_cast<uint8_t>(0), file); // reserved1
|
||||
io::write(static_cast<uint8_t>(0), file); // reserved2
|
||||
io::write(static_cast<uint8_t>(0), file); // reserved3
|
||||
io::write(static_cast<uint8_t>(0), file); // reserved4
|
||||
io::write_exact(file, tcb::as_bytes(tcb::make_span(ubjson)));
|
||||
file.close();
|
||||
|
||||
fs::rename(tmppath, realpath);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue