public BA2StateObject(BA2Reader ba2Reader) { Version = ba2Reader._version; HeaderMagic = ba2Reader._headerMagic; Type = ba2Reader._type; HasNameTable = ba2Reader.HasNameTable; }
public static async ValueTask <IBSAReader> OpenRead(AbsolutePath filename) { return(await BSASignatures.MatchesAsync(filename) switch { Definitions.FileType.TES3 => await TES3Reader.Load(new NativeFileStreamFactory(filename)), Definitions.FileType.BSA => await BSAReader.LoadAsync(new NativeFileStreamFactory(filename)), Definitions.FileType.BA2 => await BA2Reader.Load(new NativeFileStreamFactory(filename)), _ => throw new InvalidDataException("Filename is not a .bsa or .ba2") });
public static async Task <BA2Reader> Load(IStreamFactory streamFactory) { var rdr = new BA2Reader(await streamFactory.GetStream()) { _streamFactory = streamFactory }; await rdr.LoadHeaders(); return(rdr); }
public static async Task <BA2Reader> Load(AbsolutePath filename) { var rdr = new BA2Reader(await filename.OpenShared()) { _filename = filename }; await rdr.LoadHeaders(); return(rdr); }
public BA2FileEntry(BA2Reader ba2Reader, int index) { _index = index; _bsa = ba2Reader; var _rdr = ba2Reader._rdr; _nameHash = _rdr.ReadUInt32(); FullPath = _nameHash.ToString("X"); _extension = Encoding.UTF7.GetString(_rdr.ReadBytes(4)); _dirHash = _rdr.ReadUInt32(); _flags = _rdr.ReadUInt32(); _offset = _rdr.ReadUInt64(); _size = _rdr.ReadUInt32(); _realSize = _rdr.ReadUInt32(); _align = _rdr.ReadUInt32(); }
public static async ValueTask <IBSAReader> OpenRead(AbsolutePath filename) { var fourcc = ""; using (var file = await filename.OpenRead()) { fourcc = Encoding.ASCII.GetString(new BinaryReader(file).ReadBytes(4)); } if (fourcc == TES3Reader.TES3_MAGIC) { return(await TES3Reader.Load(filename)); } if (fourcc == "BSA\0") { return(await BSAReader.Load(filename)); } if (fourcc == "BTDX") { return(await BA2Reader.Load(filename)); } throw new InvalidDataException("Filename is not a .bsa or .ba2, magic " + fourcc); }
public BA2DX10Entry(BA2Reader ba2Reader, int idx) { _bsa = ba2Reader; var _rdr = ba2Reader._rdr; _nameHash = _rdr.ReadUInt32(); FullPath = _nameHash.ToString("X"); _extension = Encoding.UTF7.GetString(_rdr.ReadBytes(4)); _dirHash = _rdr.ReadUInt32(); _unk8 = _rdr.ReadByte(); _numChunks = _rdr.ReadByte(); _chunkHdrLen = _rdr.ReadUInt16(); _height = _rdr.ReadUInt16(); _width = _rdr.ReadUInt16(); _numMips = _rdr.ReadByte(); _format = _rdr.ReadByte(); _unk16 = _rdr.ReadUInt16(); _index = idx; _chunks = Enumerable.Range(0, _numChunks) .Select(_ => new BA2TextureChunk(_rdr)) .ToList(); }