Revert back to properties
This commit is contained in:
parent
52ce847c7e
commit
49093c0dbf
|
@ -36,8 +36,8 @@ fn run_main() -> Result<(), Error> {
|
|||
match element {
|
||||
Layout::SystemArea(_) => println!("SystemArea:"),
|
||||
Layout::PVD(_) => println!("PVD:"),
|
||||
Layout::Directory{name, content} => println!("Dir: {} @{}", name, content.lba),
|
||||
Layout::File(file) => println!("File: {} @{}", file, file.get_lba()),
|
||||
Layout::Directory{name, properties} => println!("Dir: {} @{}", name, properties.lba),
|
||||
Layout::File(file) => println!("File: {} @{}", file, file.properties.lba),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -18,7 +18,7 @@ pub fn collect_directory_record_member(files: &Vec<File>, dirs: &Vec<Directory>)
|
|||
let mut collection = Vec::new();
|
||||
|
||||
for file in files {
|
||||
if !file.content.is_hidden {
|
||||
if !file.properties.is_hidden {
|
||||
if let Some(name) = file.name.as_string() {
|
||||
collection.push(DirectoryRecordMember::File{name});
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ pub fn collect_directory_record_member(files: &Vec<File>, dirs: &Vec<Directory>)
|
|||
}
|
||||
|
||||
for dir in dirs {
|
||||
if !dir.content.is_hidden {
|
||||
if !dir.properties.is_hidden {
|
||||
if let Some(name) = dir.name.as_string() {
|
||||
collection.push(DirectoryRecordMember::Directory{name});
|
||||
}
|
||||
|
|
|
@ -29,12 +29,12 @@ macro_rules! declare_memory_layout {
|
|||
pub enum [< Layout$($val:camel),* >]<'a> {
|
||||
SystemArea(&'a $($val),* SystemArea),
|
||||
PVD(&'a $($val),* PrimaryVolumeDescriptor),
|
||||
Directory{name: &'a $($val),* DirectoryName, content: &'a $($val),* Content},
|
||||
Directory{name: &'a $($val),* DirectoryName, properties: &'a $($val),* Properties},
|
||||
File(&'a $($val),* File)
|
||||
}
|
||||
|
||||
fn [< add_dir_and_subdir $(_$val),* >]<'a>(layout: &mut Vec<[< Layout$($val:camel),* >]::<'a>>, dir: &'a $($val),* Directory) {
|
||||
layout.push([< Layout$($val:camel),* >]::Directory{name: &$($val),* dir.name, content: &$($val),* dir.content});
|
||||
layout.push([< Layout$($val:camel),* >]::Directory{name: &$($val),* dir.name, properties: &$($val),* dir.properties});
|
||||
for file in dir.files.[< iter$(_$val),* >]() {
|
||||
layout.push([< Layout$($val:camel),* >]::File(file));
|
||||
}
|
||||
|
|
|
@ -58,15 +58,15 @@ impl PrimaryVolumeDescriptor {
|
|||
}
|
||||
|
||||
pub struct Directory {
|
||||
pub name: DirectoryName,
|
||||
pub content: Content,
|
||||
files: Vec<File>,
|
||||
dirs: Vec<Directory>
|
||||
pub name: DirectoryName,
|
||||
pub properties: Properties,
|
||||
files: Vec<File>,
|
||||
dirs: Vec<Directory>
|
||||
}
|
||||
|
||||
impl Directory {
|
||||
pub fn new(dir_name: &str) -> Result<Directory, Error> {
|
||||
Ok(Directory{name: DirectoryName::from_str(dir_name)?, content: Content::default(), files: Vec::new(), dirs: Vec::new()})
|
||||
Ok(Directory{name: DirectoryName::from_str(dir_name)?, properties: Properties::default(), files: Vec::new(), dirs: Vec::new()})
|
||||
}
|
||||
|
||||
pub fn add_dir(&mut self, dir: Directory) {
|
||||
|
@ -77,14 +77,9 @@ impl Directory {
|
|||
self.files.push(file);
|
||||
}
|
||||
|
||||
pub fn get_lba(&self) -> usize {
|
||||
self.content.lba
|
||||
}
|
||||
|
||||
fn update_content(&mut self) {
|
||||
let dir_member = helper::collect_directory_record_member(&self.files, &self.dirs);
|
||||
|
||||
self.content.data.clear();
|
||||
println!("{} updating content", self.name.as_string().unwrap_or("<No name>".to_owned()));
|
||||
for member in dir_member {
|
||||
println!(">>> {}", member.get_name());
|
||||
|
@ -99,17 +94,14 @@ impl std::fmt::Display for Directory {
|
|||
}
|
||||
|
||||
pub struct File {
|
||||
pub name: FileName,
|
||||
pub content: Content
|
||||
pub name: FileName,
|
||||
pub properties: Properties,
|
||||
content: Vec<u8>
|
||||
}
|
||||
|
||||
impl File {
|
||||
pub fn new(file_name: &str) -> Result<File, Error> {
|
||||
Ok(File{name: FileName::from_str(file_name)?, content: Content::default()})
|
||||
}
|
||||
|
||||
pub fn get_lba(&self) -> usize {
|
||||
self.content.lba
|
||||
Ok(File{name: FileName::from_str(file_name)?, properties: Properties::default(), content: Vec::new()})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,16 +178,15 @@ impl std::fmt::Display for FileName {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct Content {
|
||||
pub struct Properties {
|
||||
pub lba: usize,
|
||||
pub overwrite_size_sectors: Option<usize>,
|
||||
pub data: Vec<u8>,
|
||||
pub is_hidden: bool
|
||||
}
|
||||
|
||||
impl Default for Content {
|
||||
impl Default for Properties {
|
||||
fn default() -> Self {
|
||||
Content{lba: 0, overwrite_size_sectors: None, data: Vec::new(), is_hidden: false}
|
||||
Properties{lba: 0, overwrite_size_sectors: None, is_hidden: false}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue