diff --git a/SabreTools.Hashing/HashTool.cs b/SabreTools.Hashing/HashTool.cs index 44ecdad..6780484 100644 --- a/SabreTools.Hashing/HashTool.cs +++ b/SabreTools.Hashing/HashTool.cs @@ -338,7 +338,7 @@ namespace SabreTools.Hashing /// Stream to hash /// Array of hash types to get from the file /// Dictionary containing hashes on success, null on error - public static Dictionary? GetStreamHashes(Stream input, HashType[] hashTypes, bool leaveOpen = false) + public static Dictionary? GetStreamHashes(Stream input, HashType[] hashTypes, long length = -1, bool leaveOpen = false) { // Create the output dictionary var hashDict = new Dictionary(); @@ -369,7 +369,7 @@ namespace SabreTools.Hashing */ // Pre load the first buffer - long refsize = input.Length; + long refsize = length > -1 ? length : input.Length; int next = refsize > buffersize ? buffersize : (int)refsize; input.Read(buffer0, 0, next); int current = next; @@ -449,7 +449,7 @@ namespace SabreTools.Hashing /// Stream to hash /// Array of hash types to get from the file /// Dictionary containing hashes on success, null on error - private static Dictionary? GetStreamHashArrays(Stream input, HashType[] hashTypes, bool leaveOpen = false) + private static Dictionary? GetStreamHashArrays(Stream input, HashType[] hashTypes, long length = -1, bool leaveOpen = false) { // Create the output dictionary var hashDict = new Dictionary(); @@ -480,7 +480,7 @@ namespace SabreTools.Hashing */ // Pre load the first buffer - long refsize = input.Length; + long refsize = length > -1 ? length : input.Length; int next = refsize > buffersize ? buffersize : (int)refsize; input.Read(buffer0, 0, next); int current = next;