Treat overlay as regular file

This commit is contained in:
Jaby 2022-12-06 01:18:01 +01:00 committed by Jaby
parent 8425590c3f
commit 3da7f77b56
4 changed files with 22 additions and 10 deletions

View File

@ -13,11 +13,6 @@
<File name="SubM.txt">../Tests/ISO_Planschbecken.xml</File>
</Directory>
</Directory>
<Directory name="Test">
<LBA-File name="New.lba" header-out="LBAs.h">
<Entry name="FirstFile">Miau.txt</Entry>
<Entry name="SecondFile">Wuff/Miau.txt</Entry>
</LBA-File>
</Directory>
<Overlay name="Main.ovl">../../../../JabyAdventure/application/bin/PSX-release/Overlay.main_area</Overlay>
</Track>
</ISO_Project>

View File

@ -20,9 +20,15 @@ pub struct CommonProperties {
pub padded_size: Option<usize>,
}
pub enum FileKind {
Regular,
Overlay
}
pub struct File {
pub common: CommonProperties,
pub path: PathBuf,
pub kind: FileKind
}
pub struct LbaFile {

View File

@ -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<File, Error> {
fn parse_regular_file(file: roxmltree::Node, is_hidden: bool) -> Result<File, Error> {
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<File, Error> {
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);

View File

@ -114,7 +114,12 @@ fn parse_configuration(config: config_reader::Configuration) -> Result<CDDesc, E
},
config_reader::DirMember::File(file) => {
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;