diff --git a/repak/src/pak.rs b/repak/src/pak.rs index 9c575b6..7b4a738 100644 --- a/repak/src/pak.rs +++ b/repak/src/pak.rs @@ -92,18 +92,21 @@ impl PakReader { for ver in Version::iter() { match Pak::read(&mut *reader, ver, key.as_ref()) { - Ok(pak) => { - return Ok(PakReader { pak, key }); - } - Err(err) => { - writeln!(log, "trying version {} failed: {}", ver, err)?; - continue; - } + Ok(pak) => return Ok(Self { pak, key }), + Err(err) => writeln!(log, "trying version {} failed: {}", ver, err)?, } } Err(super::Error::UnsuportedOrEncrypted(log)) } + pub fn new( + reader: &mut R, + version: super::Version, + key: Option, + ) -> Result { + Pak::read(reader, version, key.as_ref()).map(|pak| Self { pak, key }) + } + pub fn version(&self) -> super::Version { self.pak.version }