zipatch-rs 1.0.0

Parser for FFXIV ZiPatch patch files
Documentation
use binrw::BinRead;
use std::io::Cursor;

/// SQPK `T` command body: declares the target platform and region for following commands.
#[derive(BinRead, Debug, Clone, PartialEq, Eq)]
#[br(big)]
pub struct SqpkTargetInfo {
    /// Platform identifier: 0 = Win32, 1 = PS3, 2 = PS4, anything else = Unknown.
    #[br(pad_before = 3)]
    pub platform_id: u16,
    /// Region identifier; `-1` is Global.
    pub region: i16,
    /// `true` when the patch targets a debug build.
    #[br(map = |x: i16| x != 0)]
    pub is_debug: bool,
    /// Target client version.
    pub version: u16,
    /// Sum of bytes freed across the patch.
    #[br(little)]
    pub deleted_data_size: u64,
    /// Sum of seek operations performed; used for progress estimation.
    #[br(little)]
    pub seek_count: u64,
    // trailing 32 + 64 bytes of empty data — bounded by body slice, no pad_after needed
}

pub(crate) fn parse(body: &[u8]) -> crate::Result<SqpkTargetInfo> {
    Ok(SqpkTargetInfo::read_be(&mut Cursor::new(body))?)
}