Skip to content

Commit

Permalink
Fixed Save class not saving path before passing errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Marine committed Oct 8, 2020
1 parent 8133611 commit fd06dcf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions BotWSaveManager.Conversion/Save.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,23 @@ public enum SaveType

public Save(string folder, bool skipSwitchVersionCheck = false)
{
if (!File.Exists(Path.Combine(folder, "option.sav")))
this.SaveFolder = folder;

if (!File.Exists(Path.Combine(this.SaveFolder, "option.sav")))
{
throw new ArgumentException("The selected folder is not a valid Breath of the Wild save folder. " +
"Please select a folder containing valid save data, including option.sav " +
"in the root of the folder.");
}

using (FileStream fs = new FileStream(Path.Combine(folder, "option.sav"), FileMode.Open))
using (FileStream fs = new FileStream(Path.Combine(this.SaveFolder, "option.sav"), FileMode.Open))
using (BinaryReader br = new BinaryReader(fs))
{
byte[] check = br.ReadBytes(1);
this.SaveConsoleType = ByteArrayToString(check) == "00" ? SaveType.WiiU : SaveType.Switch;
}

foreach (string file in Directory.EnumerateFiles(folder, "game_data.sav", SearchOption.AllDirectories))
foreach (string file in Directory.EnumerateFiles(this.SaveFolder, "game_data.sav", SearchOption.AllDirectories))
{
using (FileStream fs = new FileStream(file, FileMode.Open))
using (BinaryReader br = new BinaryReader(fs))
Expand Down Expand Up @@ -153,8 +155,6 @@ public Save(string folder, bool skipSwitchVersionCheck = false)
}
}
}

this.SaveFolder = folder;
}

public Dictionary<string, byte[]> ConvertSave(string outputLocation = null)
Expand Down

0 comments on commit fd06dcf

Please sign in to comment.