Integrate all the progress into master #6
|
@ -7,11 +7,12 @@ use crate::{config_reader::Directory, types::LicenseFile};
|
|||
use super::{CDAudioFile, CommonProperties, Configuration, Error, File, FileKind, LZ4State};
|
||||
|
||||
mod attribute_names {
|
||||
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 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";
|
||||
}
|
||||
|
||||
mod tag_names {
|
||||
|
@ -68,7 +69,7 @@ fn parse_description(description: roxmltree::Node, config: &mut Configuration) -
|
|||
}
|
||||
|
||||
fn parse_altlicense_path(license: roxmltree::Node) -> LicenseFile {
|
||||
LicenseFile::from_tmd_option(path_from_node(&license, tag_names::ALTLICENSE).ok())
|
||||
LicenseFile::from_tmd_option(path_from_node(&license, tag_names::ALTLICENSE).ok(), license.attribute(attribute_names::ALTLICENSE_TEXT))
|
||||
}
|
||||
|
||||
for node in description.descendants() {
|
||||
|
|
|
@ -235,7 +235,7 @@ fn process_system_area(system_area: &SystemArea, sec_writer: &mut dyn SectorWrit
|
|||
format_if_error!(write_audio_zeros(sec_writer), "Writing license audio zeros failed with: {error_text}")
|
||||
}
|
||||
|
||||
fn write_tmd_file(sec_writer: &mut dyn SectorWriter, tmd_file: BufferedInputFile) -> Result<(), Error> {
|
||||
fn write_tmd_file(sec_writer: &mut dyn SectorWriter, tmd_file: BufferedInputFile, lic_text: &Option<String>) -> Result<(), Error> {
|
||||
fn write_license_string(sec_writer: &mut dyn SectorWriter, text: &str) -> Result<(), Error> {
|
||||
let text_len = text.len();
|
||||
|
||||
|
@ -275,10 +275,20 @@ fn process_system_area(system_area: &SystemArea, sec_writer: &mut dyn SectorWrit
|
|||
Ok(())
|
||||
}
|
||||
|
||||
format_if_error!(write_data_zeros(sec_writer), "Writing alt-license data zeros failed with: {error_text}")?;
|
||||
format_if_error!(write_license_string(sec_writer, " Not licensed by Sony Will not work on all hardware/software"), "Writing alt-license string from file failed with: {error_text}")?;
|
||||
format_if_error!(write_license_logo(sec_writer, tmd_file), "Writing alt-license logo from file failed with: {error_text}")?;
|
||||
format_if_error!(write_audio_zeros(sec_writer), "Writing alt-license audio zeros failed with: {error_text}")
|
||||
let lic_text = {
|
||||
if let Some(lic_text) = lic_text {
|
||||
lic_text.as_ref()
|
||||
}
|
||||
|
||||
else {
|
||||
""
|
||||
}
|
||||
};
|
||||
|
||||
format_if_error!(write_data_zeros(sec_writer), "Writing alt-license data zeros failed with: {error_text}")?;
|
||||
format_if_error!(write_license_string(sec_writer, lic_text), "Writing alt-license string from file failed with: {error_text}")?;
|
||||
format_if_error!(write_license_logo(sec_writer, tmd_file), "Writing alt-license logo from file failed with: {error_text}")?;
|
||||
format_if_error!(write_audio_zeros(sec_writer), "Writing alt-license audio zeros failed with: {error_text}")
|
||||
}
|
||||
|
||||
let system_area_lba = system_area.lba.get_track_relative();
|
||||
|
@ -292,10 +302,10 @@ fn process_system_area(system_area: &SystemArea, sec_writer: &mut dyn SectorWrit
|
|||
let license_file = format_if_error!(open_input_file_buffered(license_path), "Loading license file from {} failed with: {error_text}", license_path.to_string_lossy())?;
|
||||
write_license_file(sec_writer, license_file)
|
||||
},
|
||||
LicenseFile::TMD(tmd_path) => {
|
||||
LicenseFile::TMD(tmd_path, lic_text) => {
|
||||
print_warning(format!("WARNING: An alternative license file was provided. {}", NOT_BOOTING_CD_STR));
|
||||
let tmd_file = format_if_error!(open_input_file_buffered(tmd_path), "Loading TMD file from {} failed with: {error_text}", tmd_path.to_string_lossy())?;
|
||||
write_tmd_file(sec_writer, tmd_file)
|
||||
write_tmd_file(sec_writer, tmd_file, lic_text)
|
||||
},
|
||||
LicenseFile::None => {
|
||||
// No license specified - filling it with zeros
|
||||
|
|
|
@ -108,7 +108,7 @@ impl CDDesc {
|
|||
pub enum LicenseFile {
|
||||
None,
|
||||
Authentic(PathBuf),
|
||||
TMD(PathBuf)
|
||||
TMD(PathBuf, Option<String>)
|
||||
}
|
||||
|
||||
impl LicenseFile {
|
||||
|
@ -122,9 +122,16 @@ impl LicenseFile {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn from_tmd_option(option: Option<PathBuf>) -> LicenseFile {
|
||||
pub fn from_tmd_option(option: Option<PathBuf>, lic_text: Option<&str>) -> LicenseFile {
|
||||
if let Some(path) = option {
|
||||
LicenseFile::TMD(path)
|
||||
LicenseFile::TMD(path, {
|
||||
if let Some(lic_text) = lic_text {
|
||||
Some(lic_text.to_owned())
|
||||
}
|
||||
else {
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue