use physis::common::Platform;
use physis::resource::{Resource, SqPackResource};
use std::env;
use std::fs::File;
use std::io::Write;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() != 4 {
println!("Usage: extractor [game dir] [filepath_to_extract] [destination]");
return;
}
let game_dir = &args[1];
let file_path = &args[2];
let destination_path = &args[3];
let mut game_data = SqPackResource::from_existing(Platform::Win32, game_dir);
let Some(game_file) = game_data.read(file_path) else {
println!("File {} not found!", file_path);
return;
};
let Ok(mut file) = File::create(destination_path) else {
println!("Failed to open file {} for writing.", destination_path);
return;
};
if file.write_all(&game_file).is_err() {
println!("Failed to write to file {}.", destination_path);
return;
};
println!(
"Successfully extracted {} to {}!",
file_path, destination_path
);
}