mirror of
https://github.com/4sval/FModel.git
synced 2026-04-05 08:36:10 -05:00
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using System.IO;
|
|
|
|
namespace PakReader
|
|
{
|
|
public struct FByteBulkData
|
|
{
|
|
public FByteBulkDataHeader header;
|
|
public byte[] data;
|
|
|
|
internal FByteBulkData(BinaryReader reader, BinaryReader ubulk, long bulk_offset)
|
|
{
|
|
header = new FByteBulkDataHeader(reader);
|
|
|
|
data = null;
|
|
if ((header.bulk_data_flags & 0x0040) != 0)
|
|
{
|
|
data = reader.ReadBytes(header.element_count);
|
|
}
|
|
if ((header.bulk_data_flags & 0x0100) != 0)
|
|
{
|
|
if (ubulk == null)
|
|
{
|
|
throw new IOException("No ubulk specified");
|
|
}
|
|
// Archive seems "kind of" appended.
|
|
ubulk.BaseStream.Seek(header.offset_in_file + bulk_offset, SeekOrigin.Begin);
|
|
data = ubulk.ReadBytes(header.element_count);
|
|
}
|
|
|
|
if (data == null)
|
|
{
|
|
throw new IOException("Could not read data");
|
|
}
|
|
}
|
|
}
|
|
}
|