pub struct MPQFileHeader {
pub header_size: u32,
pub archive_size: u32,
pub format_version: u16,
pub sector_size_shift: u16,
pub hash_table_offset: u32,
pub block_table_offset: u32,
pub hash_table_entries: u32,
pub block_table_entries: u32,
pub extended_file_header: Option<MPQFileHeaderExt>,
pub offset: usize,
}
Expand description
The MPQ File Header
Fields§
§header_size: u32
Size of the archive header.
archive_size: u32
Size of the whole archive, including the header.
format_version: u16
MoPaQ format version.
sector_size_shift: u16
Power of two exponent specifying the number of 512-byte disk sectors in each logical sector in the archive.
hash_table_offset: u32
Offset to the beginning of the hash table,
relative to the beginning of the archive header.
To seek
it we must add the MPQFileHeader::offset
block_table_offset: u32
Offset to the beginning of the hash table,
relative to the beginning of the archive header.
To seek
it we must add the MPQFileHeader::offset
hash_table_entries: u32
Number of entries in the hash table.
block_table_entries: u32
Number of entries in the block table.
extended_file_header: Option<MPQFileHeaderExt>
Extended Block Table only present in Burning Crusade format and later:
offset: usize
Store the offset at which the FileHeader was found. this is done because other offsets are relative to this one.
Implementations§
Source§impl MPQFileHeader
impl MPQFileHeader
Sourcepub fn parse(
input: &[u8],
offset: usize,
) -> Result<(&[u8], MPQFileHeader), Err<Error<&[u8]>>>
pub fn parse( input: &[u8], offset: usize, ) -> Result<(&[u8], MPQFileHeader), Err<Error<&[u8]>>>
Parses the internal fields in the expected order.
Sourcepub fn parse_header_size(
input: &[u8],
) -> Result<(&[u8], u32), Err<Error<&[u8]>>>
pub fn parse_header_size( input: &[u8], ) -> Result<(&[u8], u32), Err<Error<&[u8]>>>
Offset 0x04
: int32 HeaderSize
Size of the archive header.
Sourcepub fn parse_archive_size(
input: &[u8],
) -> Result<(&[u8], u32), Err<Error<&[u8]>>>
pub fn parse_archive_size( input: &[u8], ) -> Result<(&[u8], u32), Err<Error<&[u8]>>>
Offset: 0x08
: int32 ArchiveSize
Size of the whole archive, including the header. Does not include the strong digital signature, if present. This size is used, among other things, for determining the region to hash in computing the digital signature. This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive is calculated as the size from the beginning of the archive to the end of the hash table, block table, or extended block table (whichever is largest).
Sourcepub fn parse_format_version(
input: &[u8],
) -> Result<(&[u8], u16), Err<Error<&[u8]>>>
pub fn parse_format_version( input: &[u8], ) -> Result<(&[u8], u16), Err<Error<&[u8]>>>
Offset 0x0c
: int16 FormatVersion
MoPaQ format version. MPQAPI will not open archives where this is negative. Known versions:
0x0000
Original format. HeaderSize should be0x20
, and large archives are not supported.0x0001
Burning Crusade format. Header size should be0x2c
, and large archives are supported.
Sourcepub fn parse_sector_size_shift(
input: &[u8],
) -> Result<(&[u8], u16), Err<Error<&[u8]>>>
pub fn parse_sector_size_shift( input: &[u8], ) -> Result<(&[u8], u16), Err<Error<&[u8]>>>
Offset 0x0e
: int8 SectorSizeShift
Power of two exponent specifying the number of 512-byte
disk sectors in each logical sector in the archive. The size
of each logical sector in the archive is:
512
* 2^SectorSizeShift
.
Bugs in the Storm library dictate that this shouldalways be:
3 (4096 byte sectors).
Sourcepub fn parse_hash_table_offset(
input: &[u8],
) -> Result<(&[u8], u32), Err<Error<&[u8]>>>
pub fn parse_hash_table_offset( input: &[u8], ) -> Result<(&[u8], u32), Err<Error<&[u8]>>>
Offset 0x10
: int32 HashTableOffset
Offset to the beginning of the hash table, relative to the beginning of the archive.
Sourcepub fn parse_block_table_offset(
input: &[u8],
) -> Result<(&[u8], u32), Err<Error<&[u8]>>>
pub fn parse_block_table_offset( input: &[u8], ) -> Result<(&[u8], u32), Err<Error<&[u8]>>>
Offset 0x14
: int32 BlockTableOffset
Offset to the beginning of the block table, relative to the beginning of the archive.
Sourcepub fn parse_hash_table_entries(
input: &[u8],
) -> Result<(&[u8], u32), Err<Error<&[u8]>>>
pub fn parse_hash_table_entries( input: &[u8], ) -> Result<(&[u8], u32), Err<Error<&[u8]>>>
Offset 0x18
: int32 HashTableEntries
Number of entries in the hash table.
Must be a power of two, and must be:
less than 2^16
for the original MoPaQ format,
or less than 2^20
for the Burning Crusade format.
Trait Implementations§
Source§impl Clone for MPQFileHeader
impl Clone for MPQFileHeader
Source§fn clone(&self) -> MPQFileHeader
fn clone(&self) -> MPQFileHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for MPQFileHeader
impl Debug for MPQFileHeader
Source§impl Default for MPQFileHeader
impl Default for MPQFileHeader
Source§fn default() -> MPQFileHeader
fn default() -> MPQFileHeader
Source§impl PartialEq for MPQFileHeader
impl PartialEq for MPQFileHeader
impl Copy for MPQFileHeader
impl StructuralPartialEq for MPQFileHeader
Auto Trait Implementations§
impl Freeze for MPQFileHeader
impl RefUnwindSafe for MPQFileHeader
impl Send for MPQFileHeader
impl Sync for MPQFileHeader
impl Unpin for MPQFileHeader
impl UnwindSafe for MPQFileHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more