SharpCompressArchiveHandler: throw fewer exceptions
This commit is contained in:
parent
e4f94fab8e
commit
4617476bcd
|
@ -25,12 +25,22 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
_archive?.Dispose();
|
||||
_archive = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// whitelist extensions, to avoid thrown exceptions
|
||||
/// </summary>
|
||||
public string[] ArchiveExtensions = { ".zip", ".gz", ".gzip", ".tar", ".rar", ".7z" };
|
||||
|
||||
public bool CheckSignature(string fileName, out int offset, out bool isExecutable)
|
||||
{
|
||||
offset = 0;
|
||||
isExecutable = false;
|
||||
|
||||
var pathExt = Path.GetExtension(fileName).ToLower();
|
||||
if (!ArchiveExtensions.Contains(pathExt))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
using (var arcTest = ArchiveFactory.Open(fileName))
|
||||
|
|
|
@ -440,7 +440,8 @@ namespace BizHawk.Common
|
|||
int offset;
|
||||
bool isExecutable;
|
||||
|
||||
if (NonArchiveExtensions.Any(ext => Path.GetExtension(path).ToLower() == ext.ToLower()))
|
||||
var pathExt = Path.GetExtension(path).ToLower();
|
||||
if (NonArchiveExtensions.Contains(pathExt))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue