mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Seek ye first the buffer for hashes
This commit is contained in:
@@ -4188,6 +4188,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
// Seek to the beginning of the stream
|
||||
if (fileStream.CanSeek)
|
||||
fileStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
Globals.Logger.User("Matches found for '{0}', rebuilding accordingly...", Path.GetFileName(datItem.Name));
|
||||
|
||||
@@ -2108,6 +2108,8 @@ namespace SabreTools.Library.Tools
|
||||
if (chdsAsFiles == false && GetCHDInfo(input) != null)
|
||||
{
|
||||
// Seek to the starting position, if one is set
|
||||
if (input.CanSeek)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (offset < 0)
|
||||
@@ -2131,6 +2133,7 @@ namespace SabreTools.Library.Tools
|
||||
{
|
||||
Globals.Logger.Warning("Stream does not support seeking to starting offset. Stream position not changed");
|
||||
}
|
||||
}
|
||||
|
||||
// Get the BaseFile from the information
|
||||
BaseFile chd = GetCHDInfo(input);
|
||||
@@ -2173,6 +2176,8 @@ namespace SabreTools.Library.Tools
|
||||
SHA512 sha512 = SHA512.Create();
|
||||
|
||||
// Seek to the starting position, if one is set
|
||||
if (input.CanSeek)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (offset < 0)
|
||||
@@ -2196,8 +2201,9 @@ namespace SabreTools.Library.Tools
|
||||
{
|
||||
Globals.Logger.Verbose("Stream does not support seeking to starting offset. Stream position not changed");
|
||||
}
|
||||
}
|
||||
|
||||
byte[] buffer = new byte[8 * 1024];
|
||||
byte[] buffer = new byte[32 * 1024 * 1024];
|
||||
int read;
|
||||
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
@@ -2268,6 +2274,8 @@ namespace SabreTools.Library.Tools
|
||||
finally
|
||||
{
|
||||
// Seek to the beginning of the stream if possible
|
||||
if (input.CanSeek)
|
||||
{
|
||||
try
|
||||
{
|
||||
input.Seek(0, SeekOrigin.Begin);
|
||||
@@ -2280,6 +2288,7 @@ namespace SabreTools.Library.Tools
|
||||
{
|
||||
Globals.Logger.Verbose("Stream does not support seeking to beginning. Stream position not changed");
|
||||
}
|
||||
}
|
||||
|
||||
if (!keepReadOpen)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user