repak/examples/version.rs

20 lines
667 B
Rust
Raw Normal View History

2023-01-11 22:42:00 +00:00
fn main() -> Result<(), un_pak::Error> {
// drag onto or open any pak with the example
let path = std::env::args().nth(1).unwrap_or_default();
for ver in un_pak::Version::iter() {
match un_pak::Pak::new(
std::io::BufReader::new(std::fs::OpenOptions::new().read(true).open(&path)?),
ver,
) {
Ok(un_pak::Pak { version, .. }) | Err(un_pak::Error::Version { version, .. }) => {
println!("{}", version);
break;
}
_ => continue,
}
}
// so you can read the results
std::thread::sleep(std::time::Duration::from_secs(10));
Ok(())
}