From cb9ca1e678797cd2ccb8d5a4df5e8260fab52f46 Mon Sep 17 00:00:00 2001 From: jaby Date: Mon, 10 Oct 2022 20:59:37 +0200 Subject: [PATCH] Replace Data with File --- src/Tools/psxcdgen_ex/src/main.rs | 18 +++++++++--------- src/Tools/psxcdgen_ex/src/types/layout.rs | 6 +++--- src/Tools/psxcdgen_ex/src/types/mod.rs | 18 +++++++++--------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Tools/psxcdgen_ex/src/main.rs b/src/Tools/psxcdgen_ex/src/main.rs index 8670e29c..ec51784e 100644 --- a/src/Tools/psxcdgen_ex/src/main.rs +++ b/src/Tools/psxcdgen_ex/src/main.rs @@ -1,28 +1,28 @@ -use psxcdgen_ex::types::{layout::Layout, CDDesc, Data, Directory}; +use psxcdgen_ex::types::{layout::Layout, CDDesc, File, Directory}; use tool_helper::Error; fn populate() -> Result { let mut desc = CDDesc::new(); - let file = Data::new("Planschi.jpg")?; - let file2 = Data::new("Wuff.png")?; + let file = File::new("Planschi.jpg")?; + let file2 = File::new("Wuff.png")?; let folder = { let mut folder = Directory::new("Sub")?; let sub_folder = { let mut folder = Directory::new("SubSub")?; - folder.add_data(Data::new("Blubb.bin")?); + folder.add_file(File::new("Blubb.bin")?); folder }; folder.add_dir(sub_folder); - folder.add_data(Data::new("Schwimm.jpg")?); - folder.add_data(Data::new("Miau.png")?); + folder.add_file(File::new("Schwimm.jpg")?); + folder.add_file(File::new("Miau.png")?); folder }; desc.root.add_dir(folder); - desc.root.add_data(file); - desc.root.add_data(file2); + desc.root.add_file(file); + desc.root.add_file(file2); Ok(desc) } @@ -34,7 +34,7 @@ fn run_main() -> Result<(), Error> { Layout::SystemArea(_) => println!("SystemArea:"), Layout::PVD(_) => println!("PVD:"), Layout::Directory{name, properties: _} => println!("Dir: {}", name), - Layout::Data(data) => println!("File: {}", data), + Layout::File(file) => println!("File: {}", file), } } Ok(()) diff --git a/src/Tools/psxcdgen_ex/src/types/layout.rs b/src/Tools/psxcdgen_ex/src/types/layout.rs index fa9c31f2..6e288a9c 100644 --- a/src/Tools/psxcdgen_ex/src/types/layout.rs +++ b/src/Tools/psxcdgen_ex/src/types/layout.rs @@ -30,13 +30,13 @@ macro_rules! declare_memory_layout { SystemArea(&'a $($val),* SystemArea), PVD(&'a $($val),* PrimaryVolumeDescriptor), Directory{name: &'a $($val),* DirectoryName, properties: &'a $($val),* Properties}, - Data(&'a $($val),* Data) + 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, properties: &$($val),* dir.properties}); - for data in dir.data.[< iter$(_$val),* >]() { - layout.push([< Layout$($val:camel),* >]::Data(data)); + for file in dir.files.[< iter$(_$val),* >]() { + layout.push([< Layout$($val:camel),* >]::File(file)); } for dir in dir.dirs.[< iter$(_$val),* >]() { diff --git a/src/Tools/psxcdgen_ex/src/types/mod.rs b/src/Tools/psxcdgen_ex/src/types/mod.rs index d1b5cb33..a591796a 100644 --- a/src/Tools/psxcdgen_ex/src/types/mod.rs +++ b/src/Tools/psxcdgen_ex/src/types/mod.rs @@ -47,21 +47,21 @@ impl PrimaryVolumeDescriptor { pub struct Directory { name: DirectoryName, properties: Properties, - data: Vec, + files: Vec, dirs: Vec } impl Directory { pub fn new(dir_name: &str) -> Result { - Ok(Directory{name: DirectoryName::from_str(dir_name)?, properties: Properties::default(), data: 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) { self.dirs.push(dir); } - pub fn add_data(&mut self, data: Data) { - self.data.push(data); + pub fn add_file(&mut self, file: File) { + self.files.push(file); } } @@ -71,18 +71,18 @@ impl std::fmt::Display for Directory { } } -pub struct Data { +pub struct File { name: FileName, properties: Properties } -impl Data { - pub fn new(file_name: &str) -> Result { - Ok(Data{name: FileName::from_str(file_name)?, properties: Properties::default()}) +impl File { + pub fn new(file_name: &str) -> Result { + Ok(File{name: FileName::from_str(file_name)?, properties: Properties::default()}) } } -impl std::fmt::Display for Data { +impl std::fmt::Display for File { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "File: {}", self.name) }