mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add safety to GetInfo methods
This commit is contained in:
@@ -47,6 +47,8 @@ namespace SabreTools.FileTypes
|
||||
if (!File.Exists(input))
|
||||
return new BaseFile();
|
||||
|
||||
try
|
||||
{
|
||||
// Get input information
|
||||
var fileType = GetFileType(input);
|
||||
Stream inputStream = GetInfoStream(input, header);
|
||||
@@ -76,6 +78,13 @@ namespace SabreTools.FileTypes
|
||||
|
||||
return baseFile;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Exceptions are currently not logged
|
||||
// TODO: Log exceptions
|
||||
return new BaseFile();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve file information for a single stream
|
||||
@@ -120,6 +129,8 @@ namespace SabreTools.FileTypes
|
||||
if (input == null)
|
||||
return new BaseFile();
|
||||
|
||||
try
|
||||
{
|
||||
// If we want to automatically set the size
|
||||
if (size == -1)
|
||||
size = input.Length;
|
||||
@@ -155,6 +166,13 @@ namespace SabreTools.FileTypes
|
||||
|
||||
return baseFile;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Exceptions are currently not logged
|
||||
// TODO: Log exceptions
|
||||
return new BaseFile();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the required stream for info hashing
|
||||
|
||||
Reference in New Issue
Block a user