pub struct MPQBlockTableEntry {
pub offset: u32,
pub archived_size: u32,
pub size: u32,
pub flags: u32,
}
Expand description
The block tables of the MPQ archive, they are stored sequentially and encrypted.
Fields§
§offset: u32
Block Offset, an offset of the beginning of the block,
relative to the beginning of the archive header, this can
be used in conjunction with fseek
to start reading a specific
block. In the case of this crate, since the contents are in memory
already, it’s used as data[(archive_header_offset + self.offset)..]
.
This is because the first section of the archive may be the UserData
section so the archive header offset must be known.
archived_size: u32
Size of the block in the archive.
size: u32
Size of the file data stored in the block.
see MPQBlockTableEntry::parse_size
for more information.
flags: u32
Bit mask of the flags for the block,
see MPQBlockTableEntry::parse_flags
for more information.
Implementations§
Source§impl MPQBlockTableEntry
impl MPQBlockTableEntry
Sourcepub fn new(offset: u32, archived_size: u32, size: u32, flags: u32) -> Self
pub fn new(offset: u32, archived_size: u32, size: u32, flags: u32) -> Self
This method is not related to parsing but for testing, maybe we should consider further splitting this into a MPQBlockTableEntryParser, maybe overkill.
Sourcepub fn parse_offset(input: &[u8]) -> IResult<&[u8], u32>
pub fn parse_offset(input: &[u8]) -> IResult<&[u8], u32>
Offset 0x00
: int32 BlockOffset
Offset of the beginning of the block, relative to the beginning of the archive header.
Sourcepub fn parse_archived_size(input: &[u8]) -> IResult<&[u8], u32>
pub fn parse_archived_size(input: &[u8]) -> IResult<&[u8], u32>
Offset 0x04
: int32 BlockSize
Size of the block in the archive.
Sourcepub fn parse_size(input: &[u8]) -> IResult<&[u8], u32>
pub fn parse_size(input: &[u8]) -> IResult<&[u8], u32>
Offset 0x08
: int32 FileSize
Size of the file data stored in the block. Only valid if the block is a file; otherwise meaningless, and should be 0. If the file is compressed, this is the size of the uncompressed file data.
Sourcepub fn parse_flags(input: &[u8]) -> IResult<&[u8], u32>
pub fn parse_flags(input: &[u8]) -> IResult<&[u8], u32>
Offset 0x0c
: int32 Flags
Bit mask of the flags for the block. The following values are conclusively identified:
0x80000000
Block is a file, and follows the file data format; otherwise, block is free space or unused. If the block is not a file, all other flags should be cleared, and FileSize should be 0.0x04000000
File has checksums for each sector (explained in the File Data section). Ignored if file is not compressed or imploded.0x02000000
File is a deletion marker, indicating that the file no longer exists. This is used to allow patch archives to delete files present in lower-priority archives in the search chain.0x01000000
File is stored as a single unit, rather than split into sectors.0x00020000
The file’s encryption key is adjusted by the block offset and file size (explained in detail in the File Data section). File must be encrypted.0x00010000
File is encrypted.0x00000200
File is compressed. File cannot be imploded.0x00000100
File is imploded. File cannot be compressed.
Trait Implementations§
Source§impl Clone for MPQBlockTableEntry
impl Clone for MPQBlockTableEntry
Source§fn clone(&self) -> MPQBlockTableEntry
fn clone(&self) -> MPQBlockTableEntry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more