From 4025ce831886351fcb1d6e7079f9107d2939ca7a Mon Sep 17 00:00:00 2001 From: Jaby Date: Tue, 6 Dec 2022 01:18:01 +0100 Subject: [PATCH] Treat overlay as regular file --- src/Tools/Tests/ISO_Planschbecken.xml | 7 +------ src/Tools/psxcdgen_ex/src/config_reader/mod.rs | 6 ++++++ src/Tools/psxcdgen_ex/src/config_reader/xml.rs | 12 +++++++++--- src/Tools/psxcdgen_ex/src/lib.rs | 7 ++++++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Tools/Tests/ISO_Planschbecken.xml b/src/Tools/Tests/ISO_Planschbecken.xml index 35fc733c..74efcb77 100644 --- a/src/Tools/Tests/ISO_Planschbecken.xml +++ b/src/Tools/Tests/ISO_Planschbecken.xml @@ -13,11 +13,6 @@ ../Tests/ISO_Planschbecken.xml - - - Miau.txt - Wuff/Miau.txt - - + ../../../../JabyAdventure/application/bin/PSX-release/Overlay.main_area \ No newline at end of file diff --git a/src/Tools/psxcdgen_ex/src/config_reader/mod.rs b/src/Tools/psxcdgen_ex/src/config_reader/mod.rs index 30746eee..15c1f399 100644 --- a/src/Tools/psxcdgen_ex/src/config_reader/mod.rs +++ b/src/Tools/psxcdgen_ex/src/config_reader/mod.rs @@ -20,9 +20,15 @@ pub struct CommonProperties { pub padded_size: Option, } +pub enum FileKind { + Regular, + Overlay +} + pub struct File { pub common: CommonProperties, pub path: PathBuf, + pub kind: FileKind } pub struct LbaFile { diff --git a/src/Tools/psxcdgen_ex/src/config_reader/xml.rs b/src/Tools/psxcdgen_ex/src/config_reader/xml.rs index 44de6e16..3306d6c9 100644 --- a/src/Tools/psxcdgen_ex/src/config_reader/xml.rs +++ b/src/Tools/psxcdgen_ex/src/config_reader/xml.rs @@ -2,7 +2,7 @@ use std::path::PathBuf; use tool_helper::format_if_error; use crate::config_reader::Directory; -use super::{CommonProperties, Configuration, Error, File}; +use super::{CommonProperties, Configuration, Error, File, FileKind}; mod attribute_names { pub const NAME: &'static str = "name"; @@ -51,18 +51,24 @@ fn parse_description(description: roxmltree::Node, config: &mut Configuration) { } fn parse_track(track: roxmltree::Node, config: &mut Configuration) -> Result<(), Error> { - fn parse_file(file: roxmltree::Node, is_hidden: bool) -> Result { + fn parse_regular_file(file: roxmltree::Node, is_hidden: bool) -> Result { Ok(File{ common: read_common_properties(&file, is_hidden)?, path: PathBuf::from(file.text().unwrap_or_default()), + kind: FileKind::Regular }) } + fn parse_overlay_file(file: roxmltree::Node, is_hidden: bool) -> Result { + parse_regular_file(file, is_hidden) + } + fn parse_file_system(cur_node: roxmltree::Node, root: &mut Directory, mut is_hidden: bool) -> Result<(), Error> { for node in cur_node.children() { if node.is_element() { match node.tag_name().name() { - "File" => root.add_file(parse_file(node, is_hidden)?), + "File" => root.add_file(parse_regular_file(node, is_hidden)?), + "Overlay" => root.add_file(parse_overlay_file(node, is_hidden)?), "Directory" => { is_hidden |= parse_boolean_attribute(&node, attribute_names::HIDDEN)?; let mut new_dir = Directory::new(node.attribute(attribute_names::NAME).unwrap_or_default(), is_hidden); diff --git a/src/Tools/psxcdgen_ex/src/lib.rs b/src/Tools/psxcdgen_ex/src/lib.rs index 2476dd23..482636ea 100644 --- a/src/Tools/psxcdgen_ex/src/lib.rs +++ b/src/Tools/psxcdgen_ex/src/lib.rs @@ -114,7 +114,12 @@ fn parse_configuration(config: config_reader::Configuration) -> Result { - let mut desc_file = types::File::new_regular(file.common.name.as_str(), read_file(file.path)?)?; + let mut desc_file = { + match file.kind { + config_reader::FileKind::Regular => types::File::new_regular(file.common.name.as_str(), read_file(file.path)?)?, + config_reader::FileKind::Overlay => types::File::new_regular(file.common.name.as_str(), read_file(file.path)?)?, + } + }; desc_file.properties.padded_size_bytes = file.common.padded_size; desc_file.properties.is_hidden = file.common.is_hidden;