diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs b/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs index e631a9b2..79d19ccf 100644 --- a/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs +++ b/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs @@ -537,6 +537,9 @@ namespace SabreTools.Helper.Dats return rebuilt; } + // Seek to the beginning of the stream + fileStream.Seek(0, SeekOrigin.Begin); + Globals.Logger.User("Matches found for '" + Style.GetFileName(rom.Name) + "', rebuilding accordingly..."); rebuilt = true; diff --git a/SabreTools.Helper/Tools/ArchiveTools.cs b/SabreTools.Helper/Tools/ArchiveTools.cs index 185b1981..d35f659c 100644 --- a/SabreTools.Helper/Tools/ArchiveTools.cs +++ b/SabreTools.Helper/Tools/ArchiveTools.cs @@ -1576,6 +1576,7 @@ namespace SabreTools.Helper.Tools if (!File.Exists(archiveFileName)) { // Copy the input stream to the output + inputStream.Seek(0, SeekOrigin.Begin); tarFile.AddEntry(rom.Name, inputStream); } @@ -1624,6 +1625,7 @@ namespace SabreTools.Helper.Tools if (index < 0) { // Copy the input file to the output + inputStream.Seek(0, SeekOrigin.Begin); tarFile.AddEntry(rom.Name, inputStream); } @@ -1871,6 +1873,9 @@ namespace SabreTools.Helper.Tools return success; } + // Seek to the beginning of the stream + inputStream.Seek(0, SeekOrigin.Begin); + // Get the output archive name from the first rebuild rom string archiveFileName = Path.Combine(outDir, Style.RemovePathUnsafeCharacters(rom.Machine.Name) + (rom.Machine.Name.EndsWith(".7z") ? "" : ".7z")); @@ -2273,7 +2278,7 @@ namespace SabreTools.Helper.Tools if (!inputStream.CanRead) { return success; - } + } // Make sure the output directory exists if (!Directory.Exists(outDir)) @@ -2442,6 +2447,9 @@ namespace SabreTools.Helper.Tools return success; } + // Seek to the beginning of the stream + inputStream.Seek(0, SeekOrigin.Begin); + // Get the output archive name from the first rebuild rom string archiveFileName = Path.Combine(outDir, Style.RemovePathUnsafeCharacters(rom.Machine.Name) + (rom.Machine.Name.EndsWith(".xz") ? "" : ".xz")); @@ -2845,7 +2853,7 @@ namespace SabreTools.Helper.Tools return success; } - // Set the stream position + // Seek to the beginning of the stream inputStream.Seek(0, SeekOrigin.Begin); // Get the output archive name from the first rebuild rom diff --git a/SabreTools.Helper/Tools/FileTools.cs b/SabreTools.Helper/Tools/FileTools.cs index 5f12a7f4..8f927240 100644 --- a/SabreTools.Helper/Tools/FileTools.cs +++ b/SabreTools.Helper/Tools/FileTools.cs @@ -839,6 +839,9 @@ namespace SabreTools.Helper.Tools } finally { + // Seek to the beginning of the stream + input.Seek(0, SeekOrigin.Begin); + if (!keepReadOpen) { input.Dispose();