2019-11-16 00:01:37 +00:00
|
|
|
|
using System.IO;
|
2019-10-06 21:58:36 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Compression.BSA
|
|
|
|
|
{
|
|
|
|
|
public static class BSADispatch
|
|
|
|
|
{
|
2019-11-16 00:01:37 +00:00
|
|
|
|
public static IBSAReader OpenRead(string filename)
|
2019-10-06 21:58:36 +00:00
|
|
|
|
{
|
2019-11-16 00:01:37 +00:00
|
|
|
|
var fourcc = "";
|
|
|
|
|
using (var file = File.OpenRead(filename))
|
2019-10-06 21:58:36 +00:00
|
|
|
|
{
|
2019-11-16 00:01:37 +00:00
|
|
|
|
fourcc = Encoding.ASCII.GetString(new BinaryReader(file).ReadBytes(4));
|
|
|
|
|
}
|
2019-10-06 21:58:36 +00:00
|
|
|
|
|
2019-11-16 00:01:37 +00:00
|
|
|
|
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);
|
2019-10-06 21:58:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|