mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Attempt to make GetInfo safer
This commit is contained in:
@@ -60,15 +60,6 @@ namespace SabreTools.FileTypes
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve file information for a single stream
|
||||
/// </summary>
|
||||
/// <param name="input">Stream to get information from</param>
|
||||
/// <param name="hashes">Hashes to include in the information</param>
|
||||
/// <returns>Populated BaseFile object if success, null on error</returns>
|
||||
public static BaseFile GetInfo(Stream? input, HashType[] hashes)
|
||||
=> GetInfo(input, size: -1, hashes, keepReadOpen: false);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve file information for a single stream
|
||||
/// </summary>
|
||||
@@ -105,9 +96,16 @@ namespace SabreTools.FileTypes
|
||||
|
||||
try
|
||||
{
|
||||
// If we want to automatically set the size
|
||||
if (size == -1)
|
||||
size = input.Length;
|
||||
try
|
||||
{
|
||||
// If we want to automatically set the size
|
||||
if (size == -1)
|
||||
size = input.Length;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Don't set the length if the stream doesn't support it
|
||||
}
|
||||
|
||||
// Run the hashing on the input stream
|
||||
var hashDict = HashTool.GetStreamHashes(input, hashes);
|
||||
|
||||
Reference in New Issue
Block a user