diff --git a/src/bin/rir.rs b/src/bin/rir.rs index 0295606..fde2ff2 100644 --- a/src/bin/rir.rs +++ b/src/bin/rir.rs @@ -69,7 +69,7 @@ fn main() { .takes_value(true).required(true)) .arg(Arg::with_name("output") .help("Output directory") - .short("o").long("output").takes_value(true).required(false)) + .short("o").long("output").takes_value(true).required(true)) .arg(Arg::with_name("overwrite") .help("Overwrite existing files") .short("f").long("force").takes_value(false).required(false))) @@ -199,7 +199,7 @@ fn cmd_bnd(args: &ArgMatches) -> i32 { fn cmd_bhf(args: &ArgMatches) -> i32 { let file_path: &str = args.value_of("file").unwrap(); - let output_path: Option<&str> = args.value_of("output"); + let output_path: &str = args.value_of("output").unwrap(); let overwrite: bool = args.is_present("overwrite"); match unpackers::bhf::extract_bhf_file(file_path, output_path, overwrite) { Err(e) => { eprintln!("Failed to extract BHF: {:?}", e); 1 } diff --git a/src/unpackers/bhf.rs b/src/unpackers/bhf.rs index ef5dc37..85af384 100644 --- a/src/unpackers/bhf.rs +++ b/src/unpackers/bhf.rs @@ -11,11 +11,9 @@ use crate::utils::fs as utils_fs; /// Extract BHF file and corresponding BDT contents to disk. /// /// Wraps around `extract_bhf` to load the BHF file from disk. -/// If output_dir is none, entries will be extracted relatively to the -/// BHF path. pub fn extract_bhf_file( bhf_path: &str, - output_dir: Option<&str>, + output_dir: &str, overwrite: bool ) -> Result<(), UnpackError> { let bhf = load_bhf_file(bhf_path)?; @@ -30,15 +28,6 @@ pub fn extract_bhf_file( }; let bdt_data = utils_fs::open_file_to_vec(&bdt_path)?; - let output_dir: &str = if output_dir.is_none() { - let parent = path::Path::new(bhf_path).parent(); - if parent.is_none() { - return Err(UnpackError::Naming(format!("Can't find BHF parent dir: {:?}", bhf_path))) - } - parent.unwrap().to_str().unwrap() // Conversion should not fail as bhf_path is valid. - } else { - output_dir.unwrap() - }; extract_bhf(&bhf, &bdt_data, output_dir, overwrite)?; Ok(()) }