Add SystemArea and PVD
This commit is contained in:
parent
50df1a1554
commit
045b9d5c48
|
@ -31,6 +31,8 @@ fn run_main() -> Result<(), Error> {
|
|||
|
||||
for element in desc.get_memory_layout().iter() {
|
||||
match element {
|
||||
Layout::SystemArea(_) => println!("SystemArea:"),
|
||||
Layout::PVD(_) => println!("PVD:"),
|
||||
Layout::Directory{name, properties: _} => println!("Dir: {}", name),
|
||||
Layout::Data(data) => println!("File: {}", data),
|
||||
}
|
||||
|
|
|
@ -18,12 +18,17 @@ macro_rules! declare_memory_layout {
|
|||
pub fn new(parent: &$($val),* CDDesc) -> Vec<[< Layout$($val:camel),* >]> {
|
||||
let mut layout = Vec::new();
|
||||
|
||||
layout.push([< Layout$($val:camel),* >]::SystemArea(&$($val),* parent.system_area));
|
||||
layout.push([< Layout$($val:camel),* >]::PVD(&$($val),* parent.pvd));
|
||||
|
||||
[< add_dir_and_subdir $(_$val),* >](&mut layout, &$($val),* parent.root);
|
||||
layout
|
||||
}
|
||||
}
|
||||
|
||||
pub enum [< Layout$($val:camel),* >]<'a> {
|
||||
SystemArea(&'a $($val),* SystemArea),
|
||||
PVD(&'a $($val),* PrimaryVolumeDescriptor),
|
||||
Directory{name: &'a $($val),* DirectoryName, properties: &'a $($val),* Properties},
|
||||
Data(&'a $($val),* Data)
|
||||
}
|
||||
|
|
|
@ -4,13 +4,15 @@ use cdtypes::types::cdstring::DString;
|
|||
use tool_helper::Error;
|
||||
|
||||
pub struct CDDesc {
|
||||
pub root: Directory
|
||||
system_area: SystemArea,
|
||||
pvd: PrimaryVolumeDescriptor,
|
||||
pub root: Directory
|
||||
}
|
||||
|
||||
impl CDDesc {
|
||||
pub fn new() -> CDDesc {
|
||||
match Directory::new("root") {
|
||||
Ok(root) => CDDesc{root},
|
||||
Ok(root) => CDDesc{system_area: SystemArea::new(), pvd: PrimaryVolumeDescriptor::new(), root},
|
||||
Err(error) => panic!("Creating root directory failed with: {}", error)
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +26,24 @@ impl CDDesc {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct SystemArea {
|
||||
}
|
||||
|
||||
impl SystemArea {
|
||||
pub fn new() -> SystemArea {
|
||||
SystemArea{}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PrimaryVolumeDescriptor {
|
||||
}
|
||||
|
||||
impl PrimaryVolumeDescriptor {
|
||||
pub fn new() -> PrimaryVolumeDescriptor {
|
||||
PrimaryVolumeDescriptor{}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Directory {
|
||||
name: DirectoryName,
|
||||
properties: Properties,
|
||||
|
@ -121,12 +141,12 @@ impl std::fmt::Display for FileName {
|
|||
|
||||
pub struct Properties {
|
||||
pub lba: Option<usize>,
|
||||
pub length: Option<usize>
|
||||
pub size_b: Option<usize>
|
||||
}
|
||||
|
||||
impl Default for Properties {
|
||||
fn default() -> Self {
|
||||
Properties{lba: None, length: None}
|
||||
Properties{lba: None, size_b: None}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue