Print content dump intro
This commit is contained in:
parent
fdabc4cf80
commit
f160b29a2d
|
@ -18,6 +18,14 @@ pub fn process(config: config_reader::Configuration, calculate_lba: CalculateLBA
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dump_content(cd_desc: &CDDesc, mut out: Output) -> Result<(), Error> {
|
pub fn dump_content(cd_desc: &CDDesc, mut out: Output) -> Result<(), Error> {
|
||||||
|
fn write_intro(out: &mut Output) -> Result<(), Error> {
|
||||||
|
writeln!(out, "File: <File name> @<Track relative LBA> - <Size in Bytes>/<Extended size in bytes>")?;
|
||||||
|
writeln!(out, "Dir: <Directory name> @<Track relative LBA>")?;
|
||||||
|
writeln!(out, "")?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn dump_dir(dir: &Directory, out: &mut Output, indent: usize) -> Result<(), Error> {
|
fn dump_dir(dir: &Directory, out: &mut Output, indent: usize) -> Result<(), Error> {
|
||||||
const INDENT_STEP:usize = 4;
|
const INDENT_STEP:usize = 4;
|
||||||
|
|
||||||
|
@ -25,8 +33,10 @@ pub fn dump_content(cd_desc: &CDDesc, mut out: Output) -> Result<(), Error> {
|
||||||
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();
|
||||||
|
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() {
|
for dir in dir.dir_iter() {
|
||||||
|
@ -41,6 +51,7 @@ pub fn dump_content(cd_desc: &CDDesc, mut out: Output) -> Result<(), Error> {
|
||||||
Ok(())
|
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}")
|
format_if_error!(dump_dir(&cd_desc.root.borrow(), &mut out, 0), "Creating content dump failed with: {error_text}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue