Use memory layout feature
This commit is contained in:
parent
0358f8673d
commit
ff51f7db68
|
@ -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;
|
use tool_helper::Error;
|
||||||
|
|
||||||
fn populate() -> Result<CDDesc, Error> {
|
fn populate() -> Result<CDDesc, Error> {
|
||||||
|
@ -27,18 +27,14 @@ fn populate() -> Result<CDDesc, Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_main() -> Result<(), Error> {
|
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()?;
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,14 @@ impl CDDesc {
|
||||||
Err(error) => panic!("Creating root directory failed with: {}", error)
|
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 {
|
pub struct Directory {
|
||||||
|
|
Loading…
Reference in New Issue