zipatch-rs 1.0.0

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

use super::util::read_null_trimmed_utf8;

/// `DELD` chunk: remove a directory under the game install root.
#[derive(BinRead, Debug, Clone, PartialEq, Eq)]
#[br(big)]
pub struct DeleteDirectory {
    /// Directory path relative to the game install root.
    #[br(parse_with = read_null_trimmed_utf8)]
    pub name: String,
}

pub(crate) fn parse(body: &[u8]) -> crate::Result<DeleteDirectory> {
    super::util::parse_be(body)
}

#[cfg(test)]
mod tests {
    use super::parse;

    #[test]
    fn parses_delete_directory() {
        let mut body = Vec::new();
        body.extend_from_slice(&4u32.to_be_bytes());
        body.extend_from_slice(b"data");
        assert_eq!(parse(&body).unwrap().name, "data");
    }
}