Prepare for calculating LBAs
This commit is contained in:
parent
c222e4b8cc
commit
de41985b16
|
@ -23,6 +23,8 @@ fn populate() -> Result<CDDesc, Error> {
|
||||||
desc.root.add_dir(folder);
|
desc.root.add_dir(folder);
|
||||||
desc.root.add_file(file);
|
desc.root.add_file(file);
|
||||||
desc.root.add_file(file2);
|
desc.root.add_file(file2);
|
||||||
|
|
||||||
|
desc.calculate_lbas();
|
||||||
Ok(desc)
|
Ok(desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +35,8 @@ fn run_main() -> Result<(), Error> {
|
||||||
match element {
|
match element {
|
||||||
Layout::SystemArea(_) => println!("SystemArea:"),
|
Layout::SystemArea(_) => println!("SystemArea:"),
|
||||||
Layout::PVD(_) => println!("PVD:"),
|
Layout::PVD(_) => println!("PVD:"),
|
||||||
Layout::Directory{name, properties: _} => println!("Dir: {}", name),
|
Layout::Directory{name, properties} => println!("Dir: {} @{}", name, properties.lba.unwrap_or(0)),
|
||||||
Layout::File(file) => println!("File: {}", file),
|
Layout::File(file) => println!("File: {} @{}", file, file.get_lba().unwrap_or(0)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
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
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod layout;
|
pub mod layout;
|
||||||
|
mod lba_calculator;
|
||||||
|
|
||||||
use cdtypes::types::cdstring::DString;
|
use cdtypes::types::cdstring::DString;
|
||||||
use tool_helper::Error;
|
use tool_helper::Error;
|
||||||
|
@ -17,6 +18,10 @@ 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 {
|
pub fn get_memory_layout(&self) -> layout::MemoryLayout {
|
||||||
layout::DefaultLayout::new(self)
|
layout::DefaultLayout::new(self)
|
||||||
}
|
}
|
||||||
|
@ -63,6 +68,10 @@ impl Directory {
|
||||||
pub fn add_file(&mut self, file: File) {
|
pub fn add_file(&mut self, file: File) {
|
||||||
self.files.push(file);
|
self.files.push(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_lba(&self) -> Option<usize> {
|
||||||
|
self.properties.lba
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Directory {
|
impl std::fmt::Display for Directory {
|
||||||
|
@ -80,6 +89,10 @@ impl File {
|
||||||
pub fn new(file_name: &str) -> Result<File, Error> {
|
pub fn new(file_name: &str) -> Result<File, Error> {
|
||||||
Ok(File{name: FileName::from_str(file_name)?, properties: Properties::default()})
|
Ok(File{name: FileName::from_str(file_name)?, properties: Properties::default()})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_lba(&self) -> Option<usize> {
|
||||||
|
self.properties.lba
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for File {
|
impl std::fmt::Display for File {
|
||||||
|
|
Loading…
Reference in New Issue