Improve properties

This commit is contained in:
Jaby 2022-10-11 19:27:34 +02:00 committed by Jaby
parent c8542ddb61
commit 2dafa1c4ce
3 changed files with 8 additions and 26 deletions

View File

@ -24,7 +24,6 @@ fn populate() -> Result<CDDesc, Error> {
desc.root.add_file(file);
desc.root.add_file(file2);
desc.calculate_lbas();
Ok(desc)
}
@ -35,8 +34,8 @@ fn run_main() -> Result<(), Error> {
match element {
Layout::SystemArea(_) => println!("SystemArea:"),
Layout::PVD(_) => println!("PVD:"),
Layout::Directory{name, properties} => println!("Dir: {} @{}", name, properties.lba.unwrap_or(0)),
Layout::File(file) => println!("File: {} @{}", file, file.get_lba().unwrap_or(0)),
Layout::Directory{name, properties} => println!("Dir: {} @{}", name, properties.lba),
Layout::File(file) => println!("File: {} @{}", file, file.get_lba()),
}
}
Ok(())

View File

@ -1,13 +0,0 @@
use super::layout::MemoryLayoutMut;
pub fn calculate(layout: MemoryLayoutMut, start_lba: usize) -> usize {
let lba = start_lba;
for element in layout.into_iter() {
match element {
_ => println!("LBA calculation not implemented yet")
}
}
lba
}

View File

@ -1,5 +1,4 @@
pub mod layout;
mod lba_calculator;
use cdtypes::types::cdstring::DString;
use tool_helper::Error;
@ -18,10 +17,6 @@ impl CDDesc {
}
}
pub fn calculate_lbas(&mut self) {
lba_calculator::calculate(self.get_memory_layout_mut(), 0);
}
pub fn get_memory_layout(&self) -> layout::MemoryLayout {
layout::DefaultLayout::new(self)
}
@ -69,7 +64,7 @@ impl Directory {
self.files.push(file);
}
pub fn get_lba(&self) -> Option<usize> {
pub fn get_lba(&self) -> usize {
self.properties.lba
}
}
@ -90,7 +85,7 @@ impl File {
Ok(File{name: FileName::from_str(file_name)?, properties: Properties::default()})
}
pub fn get_lba(&self) -> Option<usize> {
pub fn get_lba(&self) -> usize {
self.properties.lba
}
}
@ -153,13 +148,14 @@ impl std::fmt::Display for FileName {
}
pub struct Properties {
pub lba: Option<usize>,
pub size_b: Option<usize>
pub lba: usize,
pub overwrite_size_sectors: Option<usize>,
pub is_hidden: bool
}
impl Default for Properties {
fn default() -> Self {
Properties{lba: None, size_b: None}
Properties{lba: 0, overwrite_size_sectors: None, is_hidden: false}
}
}