Struct infinite_rs::module::file::ModuleFileEntry

source ·
pub struct ModuleFileEntry {
Show 25 fields pub unknown: u8, pub flags: FileEntryFlags, pub block_count: u16, pub block_index: i32, pub resource_index: i32, pub tag_group: String, pub data_offset: u64, pub data_offset_flags: DataOffsetType, pub total_compressed_size: u32, pub total_uncompressed_size: u32, pub tag_id: i32, pub uncompressed_header_size: u32, pub uncompressed_tag_data_size: u32, pub uncompressed_resource_data_size: u32, pub uncompressed_actual_resource_size: u32, pub header_alignment: u8, pub tag_data_alignment: u8, pub resource_data_alignment: u8, pub actual_resource_data_alignment: u8, pub name_offset: u32, pub parent_index: i32, pub asset_hash: i128, pub resource_count: i32, pub data_stream: Cursor<Vec<u8>>, pub tag_info: TagFile, /* private fields */
}
Expand description

Module file entry structure containing metadata relating to file and required buffer sizes and offsets for the decompressor, as well as global tag ID, resource references and class.

Fields§

§unknown: u8

Unknown, some sort of size?

§flags: FileEntryFlags

Determine how the file should be read.

§block_count: u16

Number of blocks that make up the file.

§block_index: i32

Index of the first block in the module.

§resource_index: i32

Index of the first resource in the module’s resource list.

§tag_group: String

4 byte-long string for tag group, stored as big endian. This determines how the rest of the tag is read. Example:

  • bitm: Bitmap
  • mat: Material
§data_offset: u64

Offset of compressed/uncompressed data in from the start of compressed data in the module.

§data_offset_flags: DataOffsetType

Where the offset is located. 1 if in HD1.

§total_compressed_size: u32

Size in bytes of compressed buffer in module.

§total_uncompressed_size: u32

Size in bytes of buffer to decompress into.

§tag_id: i32

MurmurHash3_x86_64 32 bit hash of tag path. Referred to in-memory as “global tag id” Is set to -1 if file is resource.

§uncompressed_header_size: u32

Size in bytes of header in decompressed buffer.

§uncompressed_tag_data_size: u32

Size in bytes of actual tag data in decompressed buffer.

§uncompressed_resource_data_size: u32

Size in bytes of resource data in decompressed buffer.

§uncompressed_actual_resource_size: u32

Size in bytes of “external” resource data in decompressed buffer. (for instance, havok data or bitmaps)

§header_alignment: u8

Power of 2 to align the header buffer to (e.g. 4 = align to a multiple of 16 bytes).

§tag_data_alignment: u8

Power of 2 to align the tag data buffer to.

§resource_data_alignment: u8

Power of 2 to align the resource data buffer to.

§actual_resource_data_alignment: u8

Power of 2 to align the actual resource data buffer to.

§name_offset: u32

Offset where the name of the file is located in the string table. This is no longer valid as of module version 52.

§parent_index: i32

Used with resources to point back to the parent file. -1 = none

§asset_hash: i128

Murmur3_x64_128 hash of (what appears to be) the original file that this file was built from. This is not always the same thing as the file stored in the module. Only verified if the HasBlocks flag is not set.

§resource_count: i32

Number of resources owned by the file.

§data_stream: Cursor<Vec<u8>>

Data stream containing a buffer of bytes to read/seek.

§tag_info: TagFile

The actual tag file read from the contents (including header), only valid if file is not a resource.

Implementations§

source§

impl ModuleFileEntry

source

pub fn new() -> Self

Allocate new ModuleFileEntry and set it to default values.

source

pub fn read<R: BufRead + BufReaderExt + Seek>( &mut self, reader: &mut R, ) -> Result<()>

Reads the metadata of a module file entry from the given reader.

§Arguments
  • reader - A mutable reference to a BufReader<File> from which to read the data.
§Returns

Returns Ok(()) if the read operation is successful, or an Err containing the I/O error if any reading operation fails.

source

pub fn read_tag( &mut self, file_path: &String, data_offset: u64, blocks: &[ModuleBlockEntry], ) -> Result<()>

Reads and loads tag data from a file.

§Arguments
  • file_path - Path to the file containing tag data.
  • data_offset - Starting offset of the data in the file.
  • blocks - Metadata for data blocks.
§Returns

Returns Ok(()) if the read operation is successful, or an (anyhow) Error containing the I/O error if any reading operation fails.

source

pub fn read_resources( &self, module: &'static ModuleFile, ) -> Result<Vec<&ModuleFileEntry>>

Reads the resources referenced by a module entry.

§Arguments
  • module - A static reference to the module of where the resources reside.
§Returns

Returns Ok(()) if the read operation is successful, or an Err containing the I/O error if any reading operation fails.

Trait Implementations§

source§

impl Debug for ModuleFileEntry

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ModuleFileEntry

source§

fn default() -> ModuleFileEntry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.