Allow any file with the correct BSA headers to be extracted with the BSA extractor.

This commit is contained in:
Timothy Baldridge 2020-05-11 06:52:23 -06:00
parent 7bc5ded82c
commit 2b5adb3d8e
2 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,5 @@
using System.IO;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Wabbajack.Common;
@ -22,5 +23,13 @@ namespace Compression.BSA
return new BA2Reader(filename);
throw new InvalidDataException("Filename is not a .bsa or .ba2, magic " + fourcc);
}
private static HashSet<string> MagicStrings = new HashSet<string> {TES3Reader.TES3_MAGIC, "BSA\0", "BTDX"};
public static bool MightBeBSA(AbsolutePath filename)
{
using var file = filename.OpenRead();
var fourcc = Encoding.ASCII.GetString(new BinaryReader(file).ReadBytes(4));
return MagicStrings.Contains(fourcc);
}
}
}

View File

@ -22,7 +22,7 @@ namespace Wabbajack.VirtualFileSystem
{
try
{
if (Consts.SupportedBSAs.Contains(source.Extension))
if (BSADispatch.MightBeBSA(source))
return await ExtractAllWithBSA(queue, source);
else if (source.Extension == Consts.OMOD)
return await ExtractAllWithOMOD(source);