Integrate all the progress into master #6
|
@ -25,50 +25,45 @@ enum SubCommands {
|
||||||
SimpleTIM(reduced_tim::Arguments)
|
SimpleTIM(reduced_tim::Arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_main() -> Result<(), Error> {
|
fn run_main(cmd: CommandLine) -> Result<(), Error> {
|
||||||
match CommandLine::try_parse() {
|
let mut input = tool_helper::open_input(cmd.input_file)?;
|
||||||
Ok(cmd) => {
|
let mut buffer = Vec::<u8>::new();
|
||||||
let mut input = tool_helper::open_input(cmd.input_file)?;
|
let mut output_file = tool_helper::open_output(cmd.output_file)?;
|
||||||
let mut buffer = Vec::<u8>::new();
|
let dst_buffer = {
|
||||||
let mut output_file = tool_helper::open_output(cmd.output_file)?;
|
if cmd.compress_lz4 {
|
||||||
let dst_buffer = {
|
&mut buffer as &mut dyn std::io::Write
|
||||||
if cmd.compress_lz4 {
|
}
|
||||||
&mut buffer as &mut dyn std::io::Write
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
else {
|
||||||
&mut output_file as &mut dyn std::io::Write
|
&mut output_file as &mut dyn std::io::Write
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match cmd.sub_command {
|
match cmd.sub_command {
|
||||||
SubCommands::Nothing => {
|
SubCommands::Nothing => {
|
||||||
std::io::copy(&mut input, dst_buffer)?;
|
std::io::copy(&mut input, dst_buffer)?;
|
||||||
},
|
|
||||||
SubCommands::SimpleTIM(args) => {
|
|
||||||
reduced_tim::convert(args, input, dst_buffer)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We encoded the file to a temporary buffer and now need to write it
|
|
||||||
if cmd.compress_lz4 {
|
|
||||||
let buffer = tool_helper::compress::psx_default::lz4(&buffer)?;
|
|
||||||
output_file.write(&buffer)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
},
|
},
|
||||||
Err(error) => Err({
|
SubCommands::SimpleTIM(args) => {
|
||||||
let mut error = Error::from_error(error);
|
reduced_tim::convert(args, input, dst_buffer)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
error.exit_code = 0;
|
// We encoded the file to a temporary buffer and now need to write it
|
||||||
error
|
if cmd.compress_lz4 {
|
||||||
})
|
let buffer = tool_helper::compress::psx_default::lz4(&buffer)?;
|
||||||
}
|
output_file.write(&buffer)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Err(error) = run_main() {
|
match CommandLine::try_parse() {
|
||||||
exit_with_error(error);
|
Ok(cmd) => {
|
||||||
|
if let Err(error) = run_main(cmd) {
|
||||||
|
exit_with_error(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(error) => eprintln!("{}", error)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue