diff --git a/lib/sdk/src/bundle/file.rs b/lib/sdk/src/bundle/file.rs index 3017ac3..f1d68c3 100644 --- a/lib/sdk/src/bundle/file.rs +++ b/lib/sdk/src/bundle/file.rs @@ -325,6 +325,7 @@ impl From for Murmur64 { struct BundleFileHeader { variant: u32, size: usize, + len_data_file_name: usize, } impl BundleFileHeader { @@ -335,26 +336,22 @@ impl BundleFileHeader { { let variant = read_u32(r).await?; skip_u8(r, 0).await?; - let size_1 = read_u32(r).await? as usize; + let size = read_u32(r).await? as usize; skip_u8(r, 1).await?; - let size_2 = read_u32(r).await? as usize; + let len_data_file_name = read_u32(r).await? as usize; - tracing::debug!(size_1, size_2); - - // NOTE: Very weird. There must be something affecting this. - let size = if size_2 == 30 { - size_1 + size_2 - } else { - size_1 - }; - - Ok(Self { size, variant }) + Ok(Self { + size, + variant, + len_data_file_name, + }) } } pub struct BundleFileVariant { header: BundleFileHeader, data: Vec, + data_file_name: String, } impl BundleFileVariant { @@ -410,7 +407,18 @@ impl BundleFile { let mut data = vec![0; header.size]; r.read_exact(&mut data).await?; - let variant = BundleFileVariant { header, data }; + let data_file_name = { + let mut buf = vec![0; header.len_data_file_name]; + r.read_exact(&mut buf).await?; + + String::from_utf8(buf)? + }; + + let variant = BundleFileVariant { + header, + data, + data_file_name, + }; variants.push(variant); } @@ -446,11 +454,12 @@ impl BundleFile { write_u8(w, 1).await?; // TODO: The previous size value and this one are somehow connected, // but so far it is unknown how - write_u32(w, 0).await?; + write_u32(w, variant.data_file_name.len() as u32).await?; } for variant in self.variants.iter() { w.write_all(&variant.data).await?; + w.write_all(variant.data_file_name.as_bytes()).await?; } Ok(()) diff --git a/lib/sdk/src/bundle/mod.rs b/lib/sdk/src/bundle/mod.rs index 7303716..ca1fd40 100644 --- a/lib/sdk/src/bundle/mod.rs +++ b/lib/sdk/src/bundle/mod.rs @@ -22,7 +22,8 @@ pub use file::BundleFile; #[derive(Clone, Copy, Debug, PartialEq)] enum BundleFormat { - Darktide, + F7, + F8, } impl TryFrom for BundleFormat { @@ -30,7 +31,8 @@ impl TryFrom for BundleFormat { fn try_from(value: u32) -> Result { match value { - 0xF0000007 => Ok(Self::Darktide), + 0xF0000007 => Ok(Self::F7), + 0xF0000008 => Ok(Self::F8), _ => Err(eyre::eyre!("Unknown bundle format '{:08X}'", value)), } } @@ -39,7 +41,8 @@ impl TryFrom for BundleFormat { impl From for u32 { fn from(value: BundleFormat) -> Self { match value { - BundleFormat::Darktide => 0xF0000007, + BundleFormat::F7 => 0xF0000007, + BundleFormat::F8 => 0xF0000008, } } } @@ -135,7 +138,7 @@ impl Bundle { .wrap_err("failed to read from file") .and_then(BundleFormat::try_from)?; - if format != BundleFormat::Darktide { + if !matches!(format, BundleFormat::F7 | BundleFormat::F8) { return Err(eyre::eyre!("Unknown bundle format: {:?}", format)); } @@ -349,7 +352,7 @@ where { let format = read_u32(&mut r).await.and_then(BundleFormat::try_from)?; - if format != BundleFormat::Darktide { + if !matches!(format, BundleFormat::F7 | BundleFormat::F8) { eyre::bail!("Unknown bundle format: {:?}", format); }