add method for known versions

This commit is contained in:
spuds 2023-08-27 15:24:47 +01:00 committed by Truman Kilen
parent b1a8281551
commit 03dd3a63ed

View file

@ -92,18 +92,21 @@ impl PakReader {
for ver in Version::iter() { for ver in Version::iter() {
match Pak::read(&mut *reader, ver, key.as_ref()) { match Pak::read(&mut *reader, ver, key.as_ref()) {
Ok(pak) => { Ok(pak) => return Ok(Self { pak, key }),
return Ok(PakReader { pak, key }); Err(err) => writeln!(log, "trying version {} failed: {}", ver, err)?,
}
Err(err) => {
writeln!(log, "trying version {} failed: {}", ver, err)?;
continue;
}
} }
} }
Err(super::Error::UnsuportedOrEncrypted(log)) Err(super::Error::UnsuportedOrEncrypted(log))
} }
pub fn new<R: Read + Seek>(
reader: &mut R,
version: super::Version,
key: Option<aes::Aes256>,
) -> Result<Self, super::Error> {
Pak::read(reader, version, key.as_ref()).map(|pak| Self { pak, key })
}
pub fn version(&self) -> super::Version { pub fn version(&self) -> super::Version {
self.pak.version self.pak.version
} }