From 8a7c32d8ba7edd42e3ce4ac5fccd8dcae2e34767 Mon Sep 17 00:00:00 2001 From: Jaby Date: Sun, 9 Oct 2022 18:17:09 +0200 Subject: [PATCH] Use memory layout feature --- src/Tools/psxcdgen_ex/src/main.rs | 18 +++++++----------- src/Tools/psxcdgen_ex/src/types/mod.rs | 8 ++++++++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Tools/psxcdgen_ex/src/main.rs b/src/Tools/psxcdgen_ex/src/main.rs index ad5fa3b4..51ccb58c 100644 --- a/src/Tools/psxcdgen_ex/src/main.rs +++ b/src/Tools/psxcdgen_ex/src/main.rs @@ -1,4 +1,4 @@ -use psxcdgen_ex::types::{iterator::{DirectoryIterator, DirectoryIteratorElement}, CDDesc, Data, Directory}; +use psxcdgen_ex::types::{layout::Layout, CDDesc, Data, Directory}; use tool_helper::Error; fn populate() -> Result { @@ -27,18 +27,14 @@ fn populate() -> Result { } fn run_main() -> Result<(), Error> { - fn dump_dir(dir: DirectoryIterator) { - for element in dir { - match element { - DirectoryIteratorElement::Directory(dir) => println!("{}", dir), - DirectoryIteratorElement::Data(data) => println!("{}", data), - } - } - - } let desc = populate()?; - dump_dir(desc.root.iter()); + for element in desc.get_memory_layout().iter() { + match element { + Layout::Directory{name, properties: _} => println!("Dir: {}", name), + Layout::Data(data) => println!("File: {}", data), + } + } Ok(()) } diff --git a/src/Tools/psxcdgen_ex/src/types/mod.rs b/src/Tools/psxcdgen_ex/src/types/mod.rs index a7458192..a8bff649 100644 --- a/src/Tools/psxcdgen_ex/src/types/mod.rs +++ b/src/Tools/psxcdgen_ex/src/types/mod.rs @@ -14,6 +14,14 @@ impl CDDesc { Err(error) => panic!("Creating root directory failed with: {}", error) } } + + pub fn get_memory_layout(&self) -> layout::MemoryLayout { + layout::DefaultLayout::new(self) + } + + pub fn get_memory_layout_mut(&mut self) -> layout::MemoryLayoutMut { + layout::DefaultLayoutMut::new(self) + } } pub struct Directory {