2020-06-09 13:45:00 +05:30
|
|
|
extern crate clap;
|
|
|
|
extern crate thinp;
|
|
|
|
|
|
|
|
use clap::{App, Arg};
|
2020-06-29 15:19:40 +05:30
|
|
|
use std::path::Path;
|
2020-06-09 13:45:00 +05:30
|
|
|
use std::process;
|
2020-06-09 17:33:39 +05:30
|
|
|
use thinp::file_utils;
|
|
|
|
|
|
|
|
use std::process::exit;
|
2020-06-09 13:45:00 +05:30
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let parser = App::new("thin_metadata_unpack")
|
2020-06-29 15:19:40 +05:30
|
|
|
.version(thinp::version::TOOLS_VERSION)
|
2020-06-09 13:45:00 +05:30
|
|
|
.about("Unpack a compressed file of thin metadata.")
|
2020-06-29 15:19:40 +05:30
|
|
|
.arg(
|
|
|
|
Arg::with_name("INPUT")
|
|
|
|
.help("Specify thinp metadata binary device/file")
|
|
|
|
.required(true)
|
|
|
|
.short("i")
|
|
|
|
.value_name("DEV")
|
|
|
|
.takes_value(true),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("OUTPUT")
|
|
|
|
.help("Specify packed output file")
|
|
|
|
.required(true)
|
|
|
|
.short("o")
|
|
|
|
.value_name("FILE")
|
|
|
|
.takes_value(true),
|
|
|
|
);
|
2020-06-09 13:45:00 +05:30
|
|
|
|
|
|
|
let matches = parser.get_matches();
|
2020-06-29 15:19:40 +05:30
|
|
|
let input_file = Path::new(matches.value_of("INPUT").unwrap());
|
|
|
|
let output_file = Path::new(matches.value_of("OUTPUT").unwrap());
|
2020-06-09 13:45:00 +05:30
|
|
|
|
2020-06-09 17:33:39 +05:30
|
|
|
if !file_utils::file_exists(input_file) {
|
2020-06-29 15:19:40 +05:30
|
|
|
eprintln!("Couldn't find input file '{}'.", &input_file.display());
|
2020-06-09 17:33:39 +05:30
|
|
|
exit(1);
|
|
|
|
}
|
2020-06-29 15:19:40 +05:30
|
|
|
|
2020-06-10 21:16:38 +05:30
|
|
|
if let Err(reason) = thinp::pack::toplevel::unpack(&input_file, &output_file) {
|
2020-06-09 13:45:00 +05:30
|
|
|
println!("Application error: {}", reason);
|
|
|
|
process::exit(1);
|
|
|
|
}
|
|
|
|
}
|