From dbb5fb9721f67788c0f3a1cc71b3def95527e6c2 Mon Sep 17 00:00:00 2001 From: Jaby Date: Thu, 17 Nov 2022 03:50:16 +0100 Subject: [PATCH] Print content dump intro --- src/Tools/psxcdgen_ex/src/lib.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Tools/psxcdgen_ex/src/lib.rs b/src/Tools/psxcdgen_ex/src/lib.rs index 6cddfae2..92116443 100644 --- a/src/Tools/psxcdgen_ex/src/lib.rs +++ b/src/Tools/psxcdgen_ex/src/lib.rs @@ -18,15 +18,25 @@ pub fn process(config: config_reader::Configuration, calculate_lba: CalculateLBA } pub fn dump_content(cd_desc: &CDDesc, mut out: Output) -> Result<(), Error> { + fn write_intro(out: &mut Output) -> Result<(), Error> { + writeln!(out, "File: @ - /")?; + writeln!(out, "Dir: @")?; + writeln!(out, "")?; + + Ok(()) + } + fn dump_dir(dir: &Directory, out: &mut Output, indent: usize) -> Result<(), Error> { const INDENT_STEP:usize = 4; for file in dir.file_iter() { - let file = file.borrow(); - let file_name = file.name.as_string().unwrap_or("".to_owned()); - let file_lba = file.get_track_rel_lba(); + let file = file.borrow(); + let file_name = file.name.as_string().unwrap_or("".to_owned()); + let file_lba = file.get_track_rel_lba(); + let file_size = file.properties.get_real_size(); + let file_ex_size = file.get_extended_size(); - writeln!(out, "{:indent$}File: {} @{}", " ", file_name, file_lba, indent=indent)?; + writeln!(out, "{:indent$}File: {} @{} - {}/{}", " ", file_name, file_lba, file_size, file_ex_size, indent=indent)?; } for dir in dir.dir_iter() { @@ -41,6 +51,7 @@ pub fn dump_content(cd_desc: &CDDesc, mut out: Output) -> Result<(), Error> { Ok(()) } + format_if_error!(write_intro(&mut out), "Writing content dump intro failed with: {error_text}")?; format_if_error!(dump_dir(&cd_desc.root.borrow(), &mut out, 0), "Creating content dump failed with: {error_text}") }