From 29560c4fa81def12767c26941a88a93bb57bab19 Mon Sep 17 00:00:00 2001 From: Jaby Date: Sat, 19 Nov 2022 02:12:48 +0100 Subject: [PATCH] Improve LBA output even more --- src/Tools/psxcdgen_ex/src/lib.rs | 35 +++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/Tools/psxcdgen_ex/src/lib.rs b/src/Tools/psxcdgen_ex/src/lib.rs index e4891108..5c202d8a 100644 --- a/src/Tools/psxcdgen_ex/src/lib.rs +++ b/src/Tools/psxcdgen_ex/src/lib.rs @@ -27,36 +27,43 @@ 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, "")?; + const NO_NAME:&'static str = ""; + const ARROW:&'static str = "|==>"; + const INDENT_STEP:usize = 4; - Ok(()) + fn write_file(out: &mut Output, indent: usize, file_name: String, file_lba: usize, file_size: usize, file_ex_size: usize) -> Result<(), Error> { + Ok(writeln!(out, "{:>indent$}File: {:{: Result<(), Error> { + Ok(writeln!(out, "{:>indent$}Dir: {: Result<(), Error> { + writeln!(out, "{:>indent$}Type: {:{: Result<(), Error> { - const ARROW:&'static str = "|==>"; - 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_name = file.name.as_string().unwrap_or(NO_NAME.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: {:{:"); + let dir_name = dir.name.as_str().unwrap_or(NO_NAME); let dir_lba = dir.get_track_rel_lba(); - writeln!(out, "{:>indent$}Dir: {: