Skip to content

Commit

Permalink
Handle the save file being used by another process (#1701) #patch
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Jan 11, 2024
1 parent d1c8cbe commit 9a910eb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ImperatorToCK3/Imperator/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using commonItems.Mods;
using ImperatorToCK3.CommonUtils.Genes;
using ImperatorToCK3.CommonUtils;
using ImperatorToCK3.Exceptions;
using ImperatorToCK3.Imperator.Diplomacy;
using ImperatorToCK3.Imperator.Armies;
using ImperatorToCK3.Imperator.Characters;
Expand Down Expand Up @@ -408,7 +409,14 @@ private void VerifySave(string saveGamePath) {
}
}
private static BufferedReader ProcessDebugModeSave(string saveGamePath) {
return new BufferedReader(File.Open(saveGamePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
try {
var fileStream = File.Open(saveGamePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
return new BufferedReader(fileStream);
} catch (IOException e) {
Logger.Debug($"Failed to open save file \"{saveGamePath}\": {e.Message}");
throw new UserErrorException("Could not open the save file! " +
"Close Imperator: Rome before running the converter.");
}
}
private static BufferedReader ProcessCompressedEncodedSave(string saveGamePath) {
Helpers.RakalyCaller.MeltSave(saveGamePath);
Expand Down

0 comments on commit 9a910eb

Please sign in to comment.