diff --git a/examples/PoolBox/iso/Config.xml b/examples/PoolBox/iso/Config.xml
index 7f4f2699..f7dacfa4 100644
--- a/examples/PoolBox/iso/Config.xml
+++ b/examples/PoolBox/iso/Config.xml
@@ -9,8 +9,10 @@
-->
Jaby
-
- %JABY_ENGINE_DIR%/bin/extern/32BIT.TMD
+
+ %PSX_LICENSE_PATH%/%PSX_LICENSE%.DAT
+
+
System.cnf.subst
diff --git a/src/Tools/psxcdgen_ex/Cargo.toml b/src/Tools/psxcdgen_ex/Cargo.toml
index 60795634..c15d93df 100644
--- a/src/Tools/psxcdgen_ex/Cargo.toml
+++ b/src/Tools/psxcdgen_ex/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "psxcdgen_ex"
-version = "1.0.1"
+version = "1.1.0"
edition = "2021"
[profile.release]
diff --git a/src/Tools/psxcdgen_ex/src/config_reader/mod.rs b/src/Tools/psxcdgen_ex/src/config_reader/mod.rs
index f1283535..9ae17022 100644
--- a/src/Tools/psxcdgen_ex/src/config_reader/mod.rs
+++ b/src/Tools/psxcdgen_ex/src/config_reader/mod.rs
@@ -21,16 +21,17 @@ impl CDAudioFile {
}
pub struct Configuration {
- pub publisher: Option,
- pub license_file: LicenseFile,
- pub root: Directory,
- pub cd_audio_files: Vec,
- pub lead_out_sectors: Option,
+ pub publisher: Option,
+ pub license_file: LicenseFile,
+ pub backup_license_file: LicenseFile,
+ pub root: Directory,
+ pub cd_audio_files: Vec,
+ pub lead_out_sectors: Option,
}
impl Configuration {
pub fn new() -> Configuration {
- Configuration{publisher: None, license_file: LicenseFile::None, root: Directory::new("root", false), cd_audio_files: Vec::new(), lead_out_sectors: None}
+ Configuration{publisher: None, license_file: LicenseFile::None, backup_license_file: LicenseFile::None, root: Directory::new("root", false), cd_audio_files: Vec::new(), lead_out_sectors: None}
}
}
diff --git a/src/Tools/psxcdgen_ex/src/config_reader/xml.rs b/src/Tools/psxcdgen_ex/src/config_reader/xml.rs
index e7345602..163383d1 100644
--- a/src/Tools/psxcdgen_ex/src/config_reader/xml.rs
+++ b/src/Tools/psxcdgen_ex/src/config_reader/xml.rs
@@ -1,27 +1,53 @@
-use attribute_names::LBA_SOURCE;
use cdtypes::types::time::Time;
use std::path::PathBuf;
-use tool_helper::{format_if_error, path_with_env_from, string_with_env_from};
+use tool_helper::{format_if_error, path_with_env_from, print_warning, string_with_env_from};
use crate::{config_reader::Directory, types::LicenseFile};
use super::{CDAudioFile, CommonProperties, Configuration, Error, File, FileKind, LZ4State};
-mod attribute_names {
+mod license_tag {
+ pub const NAME: &'static str = "License";
+ pub mod attribute {
+ pub const ALT_LOGO: &'static str = "alt-logo";
+ pub const ALT_TEXT: &'static str = "alt-text";
+ }
+}
+
+mod root_tag {
+ pub const NAME: &'static str = "PSXCD";
+ pub mod attribute {}
+}
+
+mod filesystem_tag {
+ pub const NAME: &'static str = "Filesystem";
+ pub mod attribute {
+ pub const LEAD_OUT:&'static str = "lead-out";
+ }
+}
+
+mod file_and_directory_attribute {
pub const NAME: &'static str = "name";
pub const HIDDEN: &'static str = "hidden";
pub const PADDED_SIZE: &'static str = "padded_size";
pub const LBA_SOURCE: &'static str = "lba_source";
- pub const LZ4_STATE: &'static str = "lz4";
- pub const ALTLICENSE_TEXT: &'static str = "text";
+ pub const LZ4_STATE: &'static str = "lz4";
}
-mod tag_names {
- pub const ROOT: &'static str = "PSXCD";
- pub const TRACK: &'static str = "Filesystem";
- pub const INTERLEAVED: &'static str = "InterleavedFile";
- pub const CDDA: &'static str = "AudioTrack";
- pub const LICENSE: &'static str = "License";
- pub const ALTLICENSE: &'static str = "AltLicense";
+mod interleaved_file_tag {
+ pub const NAME: &'static str = "InterleavedFile";
+ pub mod attribute {}
+}
+
+mod cdda_tag {
+ pub const NAME: &'static str = "AltLicense";
+ pub mod attribute {}
+}
+
+mod alt_license_tag {
+ pub const NAME: &'static str = "AudioTrack";
+ pub mod attribute {
+ pub const TEXT: &'static str = "text";
+ }
}
pub fn parse(xml: String) -> Result {
@@ -30,7 +56,7 @@ pub fn parse(xml: String) -> Result {
let children = parser.root().children();
for node in children {
- if node.is_element() && node.tag_name().name() == tag_names::ROOT {
+ if node.is_element() && node.tag_name().name() == root_tag::NAME {
parse_root(node, &mut config)?;
}
}
@@ -44,8 +70,8 @@ fn parse_root(root: roxmltree::Node, config: &mut Configuration) -> Result<(), E
for node in root.children() {
if node.is_element() {
match node.tag_name().name() {
- "Description" => parse_description(node, config),
- tag_names::TRACK => {
+ "Description" => parse_description(node, config),
+ filesystem_tag::NAME => {
if !parsed_track {
parsed_track = true;
parse_track(node, config)
@@ -55,7 +81,7 @@ fn parse_root(root: roxmltree::Node, config: &mut Configuration) -> Result<(), E
Err(Error::from_text(format!("Found more than 1 filesystem. Multi filesystem discs are not supported")))
}
},
- tag_names::CDDA => parse_cd_audio(node, config),
+ cdda_tag::NAME => parse_cd_audio(node, config),
_ => Ok(())
}?;
}
@@ -64,20 +90,39 @@ fn parse_root(root: roxmltree::Node, config: &mut Configuration) -> Result<(), E
}
fn parse_description(description: roxmltree::Node, config: &mut Configuration) -> Result<(), Error> {
- fn parse_license_path(license: roxmltree::Node) -> LicenseFile {
- LicenseFile::from_authentic_option(path_from_node(&license, tag_names::LICENSE).ok())
+ fn parse_license_path(license: roxmltree::Node) -> (LicenseFile, LicenseFile) {
+ let required_lic_file = LicenseFile::from_authentic_option(path_from_node(&license, license_tag::NAME).ok());
+ let alt_logo = {
+ if let Some(path) = license.attribute(license_tag::attribute::ALT_LOGO) {
+ Some(path_with_env_from(path))
+ }
+
+ else {
+ None
+ }
+ };
+ let alt_text = license.attribute(license_tag::attribute::ALT_TEXT);
+ (required_lic_file, LicenseFile::from_tmd_option(alt_logo, alt_text))
}
fn parse_altlicense_path(license: roxmltree::Node) -> LicenseFile {
- LicenseFile::from_tmd_option(path_from_node(&license, tag_names::ALTLICENSE).ok(), license.attribute(attribute_names::ALTLICENSE_TEXT))
+ LicenseFile::from_tmd_option(path_from_node(&license, alt_license_tag::NAME).ok(), license.attribute(alt_license_tag::attribute::TEXT))
}
for node in description.descendants() {
if node.is_element() {
match node.tag_name().name() {
- "Publisher" => config.publisher = Some(String::from(node.text().unwrap_or_default())),
- tag_names::LICENSE => config.license_file = parse_license_path(node),
- tag_names::ALTLICENSE => config.license_file = parse_altlicense_path(node),
+ "Publisher" => config.publisher = Some(String::from(node.text().unwrap_or_default())),
+ license_tag::NAME => (config.license_file, config.backup_license_file) = parse_license_path(node),
+ alt_license_tag::NAME => {
+ if matches!(config.license_file, LicenseFile::None) {
+ config.license_file = parse_altlicense_path(node)
+ }
+
+ else {
+ print_warning("Alternate license ignored because a (alternate) license was already provided".to_owned())
+ }
+ },
_ => ()
}
}
@@ -94,7 +139,7 @@ fn parse_track(track: roxmltree::Node, config: &mut Configuration) -> Result<(),
}
fn parse_main_file(file: roxmltree::Node) -> Result {
- if let Some(lba_path) = file.attribute(attribute_names::LBA_SOURCE) {
+ if let Some(lba_path) = file.attribute(file_and_directory_attribute::LBA_SOURCE) {
let common = read_common_properties(&file, false, Some(LZ4State::None))?;
let path = path_from_node(&file, &common.name)?;
@@ -102,7 +147,7 @@ fn parse_track(track: roxmltree::Node, config: &mut Configuration) -> Result<(),
}
else {
- tool_helper::print_warning(format!("The main file should always contain the \"{}\" attribute, even when just empty", LBA_SOURCE));
+ tool_helper::print_warning(format!("The main file should always contain the \"{}\" attribute, even when just empty", file_and_directory_attribute::LBA_SOURCE));
parse_regular_file(file, false)
}
}
@@ -112,12 +157,12 @@ fn parse_track(track: roxmltree::Node, config: &mut Configuration) -> Result<(),
let common = read_common_properties(&file, is_hidden, Some(LZ4State::AlreadyCompressed))?;
let path = path_from_node(&file, &common.name)?;
let lba_source = {
- if let Some(lba_source) = file.attribute(attribute_names::LBA_SOURCE) {
+ if let Some(lba_source) = file.attribute(file_and_directory_attribute::LBA_SOURCE) {
lba_source
}
else {
- tool_helper::print_warning(format!("Overlays should always contain the \"{}\" attribute, even when just empty", LBA_SOURCE));
+ tool_helper::print_warning(format!("Overlays should always contain the \"{}\" attribute, even when just empty", file_and_directory_attribute::LBA_SOURCE));
""
}
};
@@ -145,13 +190,13 @@ fn parse_track(track: roxmltree::Node, config: &mut Configuration) -> Result<(),
for node in cur_node.children() {
if node.is_element() {
match node.tag_name().name() {
- "File" => root.add_file(parse_regular_file(node, is_hidden)?),
- "Main" => root.add_file(parse_main_file(node)?),
- "Overlay" => root.add_file(parse_overlay_file(node, is_hidden)?),
- tag_names::INTERLEAVED => root.add_file(parse_interleaved(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);
+ "File" => root.add_file(parse_regular_file(node, is_hidden)?),
+ "Main" => root.add_file(parse_main_file(node)?),
+ "Overlay" => root.add_file(parse_overlay_file(node, is_hidden)?),
+ interleaved_file_tag::NAME => root.add_file(parse_interleaved(node, is_hidden)?),
+ "Directory" => {
+ is_hidden |= parse_boolean_attribute(&node, file_and_directory_attribute::HIDDEN)?;
+ let mut new_dir = Directory::new(node.attribute(file_and_directory_attribute::NAME).unwrap_or_default(), is_hidden);
parse_file_system(node, &mut new_dir, is_hidden)?;
root.add_dir(new_dir);
@@ -165,7 +210,6 @@ fn parse_track(track: roxmltree::Node, config: &mut Configuration) -> Result<(),
}
fn get_lead_out_sectors(track: roxmltree::Node) -> Result
+
\ No newline at end of file