From 9193bcb7c6a99f1d28a8aba69162d56d5958c76f Mon Sep 17 00:00:00 2001 From: Jaby Date: Sun, 27 Nov 2022 23:13:47 +0100 Subject: [PATCH] Support padded size --- src/Tools/Tests/ISO_Planschbecken.xml | 4 ++-- src/Tools/psxcdgen_ex/src/config_reader/xml.rs | 2 +- src/Tools/psxcdgen_ex/src/encoder/mod.rs | 2 +- src/Tools/psxcdgen_ex/src/encoder/psx.rs | 2 +- src/Tools/psxcdgen_ex/src/file_writer/mod.rs | 2 +- src/Tools/psxcdgen_ex/src/lib.rs | 5 +++-- src/Tools/psxcdgen_ex/src/main.rs | 9 +++++++-- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Tools/Tests/ISO_Planschbecken.xml b/src/Tools/Tests/ISO_Planschbecken.xml index 9c895cd5..11218098 100644 --- a/src/Tools/Tests/ISO_Planschbecken.xml +++ b/src/Tools/Tests/ISO_Planschbecken.xml @@ -4,13 +4,13 @@ - ../Tests/Test.mk + ../Tests/Test.mk ../Tests/Test.mk ../Tests/ISO_Planschbecken.xml ../Tests/ISO_Planschbecken.xml diff --git a/src/Tools/psxcdgen_ex/src/config_reader/xml.rs b/src/Tools/psxcdgen_ex/src/config_reader/xml.rs index a50a412f..48fd5513 100644 --- a/src/Tools/psxcdgen_ex/src/config_reader/xml.rs +++ b/src/Tools/psxcdgen_ex/src/config_reader/xml.rs @@ -79,7 +79,7 @@ fn parse_track(track: roxmltree::Node, config: &mut Configuration) -> Result<(), fn read_padded_size(xml: &roxmltree::Node) -> Result, Error> { if let Some(padded_attr) = xml.attribute("padded_size") { - let padded_size = format_if_error!(padded_attr.parse::(), "Failed reading {} as padded size: {error_text}", padded_attr)?; + let padded_size = format_if_error!(padded_attr.parse::(), "Failed reading \"{}\" as padded size: {error_text}", padded_attr)?; Ok(Some(padded_size)) } diff --git a/src/Tools/psxcdgen_ex/src/encoder/mod.rs b/src/Tools/psxcdgen_ex/src/encoder/mod.rs index b93c953e..3ae6d4e3 100644 --- a/src/Tools/psxcdgen_ex/src/encoder/mod.rs +++ b/src/Tools/psxcdgen_ex/src/encoder/mod.rs @@ -4,7 +4,7 @@ pub mod psx; pub mod builder; pub type LbaCalculatorFunction = fn(&mut CDDesc); -pub type ImageEncoderFunction = fn(CDDesc, &mut dyn SectorWriter) -> Result<(), Error>; +pub type ImageEncoderFunction = fn(&CDDesc, &mut dyn SectorWriter) -> Result<(), Error>; pub struct EncodingFunctions { pub lba_calculator: LbaCalculatorFunction, diff --git a/src/Tools/psxcdgen_ex/src/encoder/psx.rs b/src/Tools/psxcdgen_ex/src/encoder/psx.rs index 5e7c39e5..68dc203d 100644 --- a/src/Tools/psxcdgen_ex/src/encoder/psx.rs +++ b/src/Tools/psxcdgen_ex/src/encoder/psx.rs @@ -78,7 +78,7 @@ pub fn calculate_psx_lbas(cd_desc: &mut CDDesc) { } } -pub fn encode_psx_image(cd_desc: CDDesc, sec_writer: &mut dyn SectorWriter) -> Result<(), Error> { +pub fn encode_psx_image(cd_desc: &CDDesc, sec_writer: &mut dyn SectorWriter) -> Result<(), Error> { let vol_sector_count = cd_desc.vol_sector_count; for element in cd_desc.get_memory_layout() { diff --git a/src/Tools/psxcdgen_ex/src/file_writer/mod.rs b/src/Tools/psxcdgen_ex/src/file_writer/mod.rs index bd2ef1ce..f0f44dd6 100644 --- a/src/Tools/psxcdgen_ex/src/file_writer/mod.rs +++ b/src/Tools/psxcdgen_ex/src/file_writer/mod.rs @@ -37,7 +37,7 @@ pub trait SectorWriter { fn write(&mut self, sector: Sector) -> Result; } -pub fn write_image(cd_desc: CDDesc, encoder: ImageEncoderFunction, image_type: ImageType, mut output_path: PathBuf) -> Result<(), Error> { +pub fn write_image(cd_desc: &CDDesc, encoder: ImageEncoderFunction, image_type: ImageType, mut output_path: PathBuf) -> Result<(), Error> { match image_type { ImageType::BinCue => { output_path.set_extension("bin"); diff --git a/src/Tools/psxcdgen_ex/src/lib.rs b/src/Tools/psxcdgen_ex/src/lib.rs index fdf4bb39..efcdcfb3 100644 --- a/src/Tools/psxcdgen_ex/src/lib.rs +++ b/src/Tools/psxcdgen_ex/src/lib.rs @@ -116,7 +116,8 @@ fn parse_configuration(config: config_reader::Configuration) -> Result { let mut desc_file = types::File::new_regular(file.name.as_str(), read_file(file.path)?)?; - desc_file.properties.is_hidden = file.is_hidden; + desc_file.properties.padded_size_bytes = file.padded_size; + desc_file.properties.is_hidden = file.is_hidden; dst_dir.add_file(desc_file); }, } @@ -137,4 +138,4 @@ fn parse_configuration(config: config_reader::Configuration) -> Result Result<(), Error> { } println!("\n<== Planschbecken ==>");*/ + write_image(&desc, encoding_functions.encoder, cmd_line.output_type, cmd_line.output_file)?; + if let Some(list_content_option) = cmd_line.list_content { - psxcdgen_ex::dump_content(&desc, tool_helper::open_output(list_content_option)?)?; + psxcdgen_ex::dump_content(&desc, tool_helper::open_output(list_content_option)?) + } + + else { + Ok(()) } - write_image(desc, encoding_functions.encoder, cmd_line.output_type, cmd_line.output_file) } fn main() {