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