Treat overlay as regular file
This commit is contained in:
parent
3dab3d2075
commit
b5dc4a80a2
|
@ -13,11 +13,6 @@
|
||||||
<File name="SubM.txt">../Tests/ISO_Planschbecken.xml</File>
|
<File name="SubM.txt">../Tests/ISO_Planschbecken.xml</File>
|
||||||
</Directory>
|
</Directory>
|
||||||
</Directory>
|
</Directory>
|
||||||
<Directory name="Test">
|
<Overlay name="Main.ovl">../../../../JabyAdventure/application/bin/PSX-release/Overlay.main_area</Overlay>
|
||||||
<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>
|
|
||||||
</Track>
|
</Track>
|
||||||
</ISO_Project>
|
</ISO_Project>
|
|
@ -20,9 +20,15 @@ pub struct CommonProperties {
|
||||||
pub padded_size: Option<usize>,
|
pub padded_size: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum FileKind {
|
||||||
|
Regular,
|
||||||
|
Overlay
|
||||||
|
}
|
||||||
|
|
||||||
pub struct File {
|
pub struct File {
|
||||||
pub common: CommonProperties,
|
pub common: CommonProperties,
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
|
pub kind: FileKind
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LbaFile {
|
pub struct LbaFile {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::path::PathBuf;
|
||||||
use tool_helper::format_if_error;
|
use tool_helper::format_if_error;
|
||||||
use crate::config_reader::Directory;
|
use crate::config_reader::Directory;
|
||||||
|
|
||||||
use super::{CommonProperties, Configuration, Error, File};
|
use super::{CommonProperties, Configuration, Error, File, FileKind};
|
||||||
|
|
||||||
mod attribute_names {
|
mod attribute_names {
|
||||||
pub const NAME: &'static str = "name";
|
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_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{
|
Ok(File{
|
||||||
common: read_common_properties(&file, is_hidden)?,
|
common: read_common_properties(&file, is_hidden)?,
|
||||||
path: PathBuf::from(file.text().unwrap_or_default()),
|
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> {
|
fn parse_file_system(cur_node: roxmltree::Node, root: &mut Directory, mut is_hidden: bool) -> Result<(), Error> {
|
||||||
for node in cur_node.children() {
|
for node in cur_node.children() {
|
||||||
if node.is_element() {
|
if node.is_element() {
|
||||||
match node.tag_name().name() {
|
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" => {
|
"Directory" => {
|
||||||
is_hidden |= parse_boolean_attribute(&node, attribute_names::HIDDEN)?;
|
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);
|
let mut new_dir = Directory::new(node.attribute(attribute_names::NAME).unwrap_or_default(), is_hidden);
|
||||||
|
|
|
@ -114,7 +114,12 @@ fn parse_configuration(config: config_reader::Configuration) -> Result<CDDesc, E
|
||||||
},
|
},
|
||||||
|
|
||||||
config_reader::DirMember::File(file) => {
|
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.padded_size_bytes = file.common.padded_size;
|
||||||
desc_file.properties.is_hidden = file.common.is_hidden;
|
desc_file.properties.is_hidden = file.common.is_hidden;
|
||||||
|
|
Loading…
Reference in New Issue