wabbajack/Compression.BSA/BSADispatch.cs
2019-11-15 17:01:37 -07:00

24 lines
658 B
C#

using System.IO;
using System.Text;
namespace Compression.BSA
{
public static class BSADispatch
{
public static IBSAReader OpenRead(string filename)
{
var fourcc = "";
using (var file = File.OpenRead(filename))
{
fourcc = Encoding.ASCII.GetString(new BinaryReader(file).ReadBytes(4));
}
if (fourcc == "BSA\0")
return new BSAReader(filename);
if (fourcc == "BTDX")
return new BA2Reader(filename);
throw new InvalidDataException("Filename is not a .bsa or .ba2, magic " + fourcc);
}
}
}