From 44b1100686967c471518bd809eb106d4479cbb7c Mon Sep 17 00:00:00 2001 From: Brett Mayson Date: Sat, 9 Nov 2024 03:18:23 +0000 Subject: [PATCH] don't require vers header --- libs/pbo/src/error.rs | 3 --- libs/pbo/src/read.rs | 8 +++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libs/pbo/src/error.rs b/libs/pbo/src/error.rs index 3944536a..641d2295 100644 --- a/libs/pbo/src/error.rs +++ b/libs/pbo/src/error.rs @@ -7,9 +7,6 @@ pub enum Error { /// [`std::io::Error`] Io(#[from] std::io::Error), - #[error("Missing Vers header")] - /// Missing Vers header - NoVersHeader, #[error("HEMTT does not support the encountered PBO Mime type: {0}")] /// HEMTT does not support the encountered PBO Mime type UnsupportedMime(u32), diff --git a/libs/pbo/src/read.rs b/libs/pbo/src/read.rs index 978ecfd0..980525ee 100644 --- a/libs/pbo/src/read.rs +++ b/libs/pbo/src/read.rs @@ -15,7 +15,7 @@ use crate::{ /// An existing PBO file that can be read from pub struct ReadablePbo { properties: IndexMap, - vers_header: Header, + vers_header: Option
, headers: Vec
, checksum: Checksum, input: I, @@ -54,7 +54,7 @@ impl ReadablePbo { } } - let vers_header = vers_header.ok_or(Error::NoVersHeader)?; + let vers_header = vers_header; for header in &headers { input.seek(SeekFrom::Current(i64::from(header.size())))?; @@ -177,7 +177,9 @@ impl ReadablePbo { /// if a file does not exist, but a header for it does pub fn gen_checksum(&mut self) -> Result { let mut headers: Cursor> = Cursor::new(Vec::new()); - self.vers_header.write_pbo(&mut headers)?; + if let Some(vers_header) = &self.vers_header { + vers_header.write_pbo(&mut headers)?; + } if let Some(prefix) = self.properties.get("prefix") { headers.write_cstring(b"prefix")?;