mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
fix: Issues where files are only being partially overwritten instead of truncated
This commit is contained in:
@@ -237,8 +237,7 @@ namespace hex {
|
||||
for (const auto &directory : fs::getDefaultPaths(fs::ImHexPath::Config)) {
|
||||
auto path = directory / AchievementsFile;
|
||||
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Write);
|
||||
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Create);
|
||||
if (!file.isValid()) {
|
||||
continue;
|
||||
}
|
||||
@@ -254,7 +253,6 @@ namespace hex {
|
||||
}
|
||||
|
||||
const auto result = json.dump(4);
|
||||
file.setSize(0);
|
||||
file.writeString(result);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -130,10 +130,9 @@ namespace hex {
|
||||
return;
|
||||
}
|
||||
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Config)) {
|
||||
wolv::io::File file(dir / SettingsFile, wolv::io::File::Mode::Write);
|
||||
wolv::io::File file(dir / SettingsFile, wolv::io::File::Mode::Create);
|
||||
|
||||
if (file.isValid()) {
|
||||
file.setSize(0);
|
||||
file.writeString(result);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace hex {
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Read);
|
||||
if (!file.isValid()) {
|
||||
log::error("Failed to load workspace from file '{}'", path.string());
|
||||
file.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,6 +57,7 @@ namespace hex {
|
||||
};
|
||||
} catch (nlohmann::json::exception &e) {
|
||||
log::error("Failed to load workspace from file '{}': {}", path.string(), e.what());
|
||||
file.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user