Support padded size
This commit is contained in:
parent
94b4bd2b2f
commit
9a23a736ea
|
@ -4,13 +4,13 @@
|
||||||
<!--<License>../Tests/ISO_Planschbecken.xml</License>-->
|
<!--<License>../Tests/ISO_Planschbecken.xml</License>-->
|
||||||
</Description>
|
</Description>
|
||||||
<Track>
|
<Track>
|
||||||
<File name="Miau.txt">../Tests/Test.mk</File>
|
<File name="Miau.txt" padded_size="4096">../Tests/Test.mk</File>
|
||||||
<File name="Miau2.txt">../Tests/Test.mk</File>
|
<File name="Miau2.txt">../Tests/Test.mk</File>
|
||||||
<Audiofile>../Tests/ISO_Planschbecken.xml</Audiofile>
|
<Audiofile>../Tests/ISO_Planschbecken.xml</Audiofile>
|
||||||
<Directory name="Wuff">
|
<Directory name="Wuff">
|
||||||
<File name="Miau.txt" type="file">../Tests/ISO_Planschbecken.xml</File>
|
<File name="Miau.txt" type="file">../Tests/ISO_Planschbecken.xml</File>
|
||||||
<Directory name="Sub" hidden="true">
|
<Directory name="Sub" hidden="true">
|
||||||
<File name="SubM.txt" type="file" padded_size="planschi">../Tests/ISO_Planschbecken.xml</File>
|
<File name="SubM.txt" type="file">../Tests/ISO_Planschbecken.xml</File>
|
||||||
</Directory>
|
</Directory>
|
||||||
</Directory>
|
</Directory>
|
||||||
</Track>
|
</Track>
|
||||||
|
|
|
@ -79,7 +79,7 @@ fn parse_track(track: roxmltree::Node, config: &mut Configuration) -> Result<(),
|
||||||
|
|
||||||
fn read_padded_size(xml: &roxmltree::Node) -> Result<Option<usize>, Error> {
|
fn read_padded_size(xml: &roxmltree::Node) -> Result<Option<usize>, Error> {
|
||||||
if let Some(padded_attr) = xml.attribute("padded_size") {
|
if let Some(padded_attr) = xml.attribute("padded_size") {
|
||||||
let padded_size = format_if_error!(padded_attr.parse::<usize>(), "Failed reading {} as padded size: {error_text}", padded_attr)?;
|
let padded_size = format_if_error!(padded_attr.parse::<usize>(), "Failed reading \"{}\" as padded size: {error_text}", padded_attr)?;
|
||||||
Ok(Some(padded_size))
|
Ok(Some(padded_size))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ pub mod psx;
|
||||||
pub mod builder;
|
pub mod builder;
|
||||||
|
|
||||||
pub type LbaCalculatorFunction = fn(&mut CDDesc);
|
pub type LbaCalculatorFunction = fn(&mut CDDesc);
|
||||||
pub type ImageEncoderFunction = fn(CDDesc, &mut dyn SectorWriter) -> Result<(), Error>;
|
pub type ImageEncoderFunction = fn(&CDDesc, &mut dyn SectorWriter) -> Result<(), Error>;
|
||||||
|
|
||||||
pub struct EncodingFunctions {
|
pub struct EncodingFunctions {
|
||||||
pub lba_calculator: LbaCalculatorFunction,
|
pub lba_calculator: LbaCalculatorFunction,
|
||||||
|
|
|
@ -78,7 +78,7 @@ pub fn calculate_psx_lbas(cd_desc: &mut CDDesc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn encode_psx_image(cd_desc: CDDesc, sec_writer: &mut dyn SectorWriter) -> Result<(), Error> {
|
pub fn encode_psx_image(cd_desc: &CDDesc, sec_writer: &mut dyn SectorWriter) -> Result<(), Error> {
|
||||||
let vol_sector_count = cd_desc.vol_sector_count;
|
let vol_sector_count = cd_desc.vol_sector_count;
|
||||||
|
|
||||||
for element in cd_desc.get_memory_layout() {
|
for element in cd_desc.get_memory_layout() {
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub trait SectorWriter {
|
||||||
fn write(&mut self, sector: Sector) -> Result<usize, Error>;
|
fn write(&mut self, sector: Sector) -> Result<usize, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_image(cd_desc: CDDesc, encoder: ImageEncoderFunction, image_type: ImageType, mut output_path: PathBuf) -> Result<(), Error> {
|
pub fn write_image(cd_desc: &CDDesc, encoder: ImageEncoderFunction, image_type: ImageType, mut output_path: PathBuf) -> Result<(), Error> {
|
||||||
match image_type {
|
match image_type {
|
||||||
ImageType::BinCue => {
|
ImageType::BinCue => {
|
||||||
output_path.set_extension("bin");
|
output_path.set_extension("bin");
|
||||||
|
|
|
@ -116,7 +116,8 @@ 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.name.as_str(), read_file(file.path)?)?;
|
let mut desc_file = types::File::new_regular(file.name.as_str(), read_file(file.path)?)?;
|
||||||
|
|
||||||
desc_file.properties.is_hidden = file.is_hidden;
|
desc_file.properties.padded_size_bytes = file.padded_size;
|
||||||
|
desc_file.properties.is_hidden = file.is_hidden;
|
||||||
dst_dir.add_file(desc_file);
|
dst_dir.add_file(desc_file);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -137,4 +138,4 @@ fn parse_configuration(config: config_reader::Configuration) -> Result<CDDesc, E
|
||||||
|
|
||||||
parse_dir(&mut cd_desc.root.borrow_mut(), config.root)?;
|
parse_dir(&mut cd_desc.root.borrow_mut(), config.root)?;
|
||||||
Ok(cd_desc)
|
Ok(cd_desc)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,15 @@ fn run_main(cmd_line: CommandLine) -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
println!("\n<== Planschbecken ==>");*/
|
println!("\n<== Planschbecken ==>");*/
|
||||||
|
|
||||||
|
write_image(&desc, encoding_functions.encoder, cmd_line.output_type, cmd_line.output_file)?;
|
||||||
|
|
||||||
if let Some(list_content_option) = cmd_line.list_content {
|
if let Some(list_content_option) = cmd_line.list_content {
|
||||||
psxcdgen_ex::dump_content(&desc, tool_helper::open_output(list_content_option)?)?;
|
psxcdgen_ex::dump_content(&desc, tool_helper::open_output(list_content_option)?)
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
write_image(desc, encoding_functions.encoder, cmd_line.output_type, cmd_line.output_file)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
Loading…
Reference in New Issue