UESaveFile: prevent reloading data on save.
This commit is contained in:
parent
f500e982e6
commit
48210c7186
2 changed files with 22 additions and 1 deletions
|
@ -39,6 +39,10 @@ auto UESaveFile::lastError() const -> const std::string& {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto UESaveFile::reloadData() -> bool {
|
auto UESaveFile::reloadData() -> bool {
|
||||||
|
if(_noReloadAfterSave) {
|
||||||
|
return valid();
|
||||||
|
}
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
return valid();
|
return valid();
|
||||||
}
|
}
|
||||||
|
@ -48,7 +52,7 @@ auto UESaveFile::props() -> Containers::ArrayView<UnrealPropertyBase::ptr> {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto UESaveFile::saveToFile() -> bool {
|
auto UESaveFile::saveToFile() -> bool {
|
||||||
BinaryWriter writer{_filepath + ".other"};
|
BinaryWriter writer{_filepath + ".tmp"};
|
||||||
|
|
||||||
if(!writer.open()) {
|
if(!writer.open()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -97,6 +101,21 @@ auto UESaveFile::saveToFile() -> bool {
|
||||||
|
|
||||||
writer.writeUnsignedInt(0);
|
writer.writeUnsignedInt(0);
|
||||||
|
|
||||||
|
if(!Utility::Directory::copy(_filepath, _filepath + ".bak")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Utility::Directory::rm(_filepath)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!Utility::Directory::move(_filepath + ".tmp", _filepath)) {
|
||||||
|
Utility::Directory::move(_filepath + ".bak", _filepath);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_noReloadAfterSave = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ class UESaveFile {
|
||||||
|
|
||||||
std::string _filepath;
|
std::string _filepath;
|
||||||
|
|
||||||
|
bool _noReloadAfterSave = false;
|
||||||
|
|
||||||
Containers::StaticArray<4, char> _magicBytes{'G', 'V', 'A', 'S'};
|
Containers::StaticArray<4, char> _magicBytes{'G', 'V', 'A', 'S'};
|
||||||
|
|
||||||
UnsignedInt _saveVersion = 0;
|
UnsignedInt _saveVersion = 0;
|
||||||
|
|
Loading…
Reference in a new issue