Improve lba_source handling

This commit is contained in:
2024-07-21 20:46:29 +02:00
parent aaab604f61
commit a624de92a1
3 changed files with 23 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "psxcdgen_ex"
version = "0.6.0"
version = "1.0.0"
edition = "2021"
[profile.release]

View File

@@ -1,3 +1,4 @@
use attribute_names::LBA_SOURCE;
use cdtypes::types::time::Time;
use std::path::PathBuf;
use tool_helper::{format_if_error, path_with_env_from, print_warning, string_with_env_from};
@@ -86,16 +87,26 @@ 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));
parse_regular_file(file, false)
}
}
fn parse_overlay_file(file: roxmltree::Node, is_hidden: bool) -> Result<File, Error> {
// v They will be compressed automatically
let common = read_common_properties(&file, is_hidden, Some(LZ4State::AlreadyCompressed))?;
let path = path_from_node(&file, &common.name)?;
// v They will be compressed automatically
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) {
lba_source
}
Ok(File{common, path, kind: FileKind::Overlay(PathBuf::from(file.attribute(attribute_names::LBA_SOURCE).unwrap_or_default()))})
else {
tool_helper::print_warning(format!("Overlays should always contain the \"{}\" attribute, even when just empty", LBA_SOURCE));
""
}
};
Ok(File{common, path, kind: FileKind::Overlay(PathBuf::from(lba_source))})
}
fn parse_xa_audio(file: roxmltree::Node, is_hidden: bool) -> Result<File, Error> {