Skip to main content

zipatch_rs/chunk/
ddir.rs

1use binrw::BinRead;
2
3use super::util::read_null_trimmed_utf8;
4
5/// `DELD` chunk: remove a directory under the game install root.
6#[derive(BinRead, Debug, Clone, PartialEq, Eq)]
7#[br(big)]
8pub struct DeleteDirectory {
9    /// Directory path relative to the game install root.
10    #[br(parse_with = read_null_trimmed_utf8)]
11    pub name: String,
12}
13
14pub(crate) fn parse(body: &[u8]) -> crate::Result<DeleteDirectory> {
15    super::util::parse_be(body)
16}
17
18#[cfg(test)]
19mod tests {
20    use super::parse;
21
22    #[test]
23    fn parses_delete_directory() {
24        let mut body = Vec::new();
25        body.extend_from_slice(&4u32.to_be_bytes());
26        body.extend_from_slice(b"data");
27        assert_eq!(parse(&body).unwrap().name, "data");
28    }
29}