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))
|
if (!File.Exists(input))
|
||||||
return new BaseFile();
|
return new BaseFile();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// Get input information
|
// Get input information
|
||||||
var fileType = GetFileType(input);
|
var fileType = GetFileType(input);
|
||||||
Stream inputStream = GetInfoStream(input, header);
|
Stream inputStream = GetInfoStream(input, header);
|
||||||
@@ -76,6 +78,13 @@ namespace SabreTools.FileTypes
|
|||||||
|
|
||||||
return baseFile;
|
return baseFile;
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Exceptions are currently not logged
|
||||||
|
// TODO: Log exceptions
|
||||||
|
return new BaseFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve file information for a single stream
|
/// Retrieve file information for a single stream
|
||||||
@@ -120,6 +129,8 @@ namespace SabreTools.FileTypes
|
|||||||
if (input == null)
|
if (input == null)
|
||||||
return new BaseFile();
|
return new BaseFile();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// If we want to automatically set the size
|
// If we want to automatically set the size
|
||||||
if (size == -1)
|
if (size == -1)
|
||||||
size = input.Length;
|
size = input.Length;
|
||||||
@@ -155,6 +166,13 @@ namespace SabreTools.FileTypes
|
|||||||
|
|
||||||
return baseFile;
|
return baseFile;
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Exceptions are currently not logged
|
||||||
|
// TODO: Log exceptions
|
||||||
|
return new BaseFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the required stream for info hashing
|
/// Get the required stream for info hashing
|
||||||
|
|||||||
Reference in New Issue
Block a user