Improve output design
This commit is contained in:
parent
04e137aec8
commit
fdabc4cf80
|
@ -17,14 +17,16 @@ pub fn process(config: config_reader::Configuration, calculate_lba: CalculateLBA
|
||||||
Ok(cd_desc)
|
Ok(cd_desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dump_content(cd_desc: &CDDesc, out: Output) -> Result<(), Error> {
|
pub fn dump_content(cd_desc: &CDDesc, mut out: Output) -> Result<(), Error> {
|
||||||
fn dump_dir(dir: &Directory, mut out: Output) -> Result<(), Error> {
|
fn dump_dir(dir: &Directory, out: &mut Output, indent: usize) -> Result<(), Error> {
|
||||||
|
const INDENT_STEP:usize = 4;
|
||||||
|
|
||||||
for file in dir.file_iter() {
|
for file in dir.file_iter() {
|
||||||
let file = file.borrow();
|
let file = file.borrow();
|
||||||
let file_name = file.name.as_string().unwrap_or("<No name>".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_lba = file.get_track_rel_lba();
|
||||||
|
|
||||||
writeln!(out, "File: {} @{}", file_name, file_lba)?;
|
writeln!(out, "{:indent$}File: {} @{}", " ", file_name, file_lba, indent=indent)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
for dir in dir.dir_iter() {
|
for dir in dir.dir_iter() {
|
||||||
|
@ -32,13 +34,14 @@ pub fn dump_content(cd_desc: &CDDesc, out: Output) -> Result<(), Error> {
|
||||||
let dir_name = dir.name.as_str().unwrap_or("<No name>");
|
let dir_name = dir.name.as_str().unwrap_or("<No name>");
|
||||||
let dir_lba = dir.get_track_rel_lba();
|
let dir_lba = dir.get_track_rel_lba();
|
||||||
|
|
||||||
writeln!(out, "Dir: {} @{}", dir_name, dir_lba)?;
|
writeln!(out, "{:indent$}Dir: {} @{}", " ", dir_name, dir_lba, indent=indent)?;
|
||||||
|
dump_dir(&dir, out, indent + INDENT_STEP)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
format_if_error!(dump_dir(&cd_desc.root.borrow(), out), "Creating content dump failed with: {error_text}")
|
format_if_error!(dump_dir(&cd_desc.root.borrow(), &mut out, 0), "Creating content dump failed with: {error_text}")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_configuration(config: config_reader::Configuration) -> Result<CDDesc, Error> {
|
fn parse_configuration(config: config_reader::Configuration) -> Result<CDDesc, Error> {
|
||||||
|
|
Loading…
Reference in New Issue