Prepare bin/cue writer
This commit is contained in:
0
src/Tools/psxcdgen_ex/planschi.bin
Normal file
0
src/Tools/psxcdgen_ex/planschi.bin
Normal file
1
src/Tools/psxcdgen_ex/src/encoder/mod.rs
Normal file
1
src/Tools/psxcdgen_ex/src/encoder/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod psx;
|
0
src/Tools/psxcdgen_ex/src/encoder/psx.rs
Normal file
0
src/Tools/psxcdgen_ex/src/encoder/psx.rs
Normal file
25
src/Tools/psxcdgen_ex/src/file_writer/bin_cue.rs
Normal file
25
src/Tools/psxcdgen_ex/src/file_writer/bin_cue.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use std::io::Write;
|
||||
use super::{Error, SectorWriter};
|
||||
|
||||
pub struct BinCueWriter {
|
||||
_bin_out: std::boxed::Box<dyn Write>,
|
||||
sector_count: usize
|
||||
}
|
||||
|
||||
impl BinCueWriter {
|
||||
pub fn new<T: Write + 'static>(writer: T) -> BinCueWriter {
|
||||
BinCueWriter{_bin_out: std::boxed::Box::new(writer), sector_count: 0}
|
||||
}
|
||||
}
|
||||
|
||||
impl SectorWriter for BinCueWriter {
|
||||
fn write(&mut self) -> Result<(), Error> {
|
||||
self.sector_count += 1;
|
||||
|
||||
Err(Error::not_implemented("write for BinCueWriter"))
|
||||
}
|
||||
|
||||
fn sector_written_count(&self) -> usize {
|
||||
self.sector_count
|
||||
}
|
||||
}
|
25
src/Tools/psxcdgen_ex/src/file_writer/mod.rs
Normal file
25
src/Tools/psxcdgen_ex/src/file_writer/mod.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
pub mod bin_cue;
|
||||
|
||||
use bin_cue::BinCueWriter;
|
||||
use super::types::CDDesc;
|
||||
use std::path::PathBuf;
|
||||
use tool_helper::{Error, open_output_file};
|
||||
|
||||
pub enum ImageType {
|
||||
BinCue
|
||||
}
|
||||
|
||||
pub trait SectorWriter {
|
||||
fn write(&mut self) -> Result<(), Error>;
|
||||
fn sector_written_count(&self) -> usize;
|
||||
}
|
||||
|
||||
pub fn write_image(_cd_desc: CDDesc, image_type: ImageType, output_path: PathBuf) -> Result<(), Error> {
|
||||
match image_type {
|
||||
ImageType::BinCue => {
|
||||
let mut _writer = BinCueWriter::new(open_output_file(output_path)?);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
@@ -1 +1,2 @@
|
||||
pub mod file_writer;
|
||||
pub mod types;
|
@@ -1,4 +1,5 @@
|
||||
use psxcdgen_ex::types::{layout::Layout, CDDesc, File, Directory};
|
||||
use psxcdgen_ex::{file_writer::{ImageType, write_image}, types::{layout::Layout, CDDesc, File, Directory}};
|
||||
use std::{path::PathBuf, str::FromStr};
|
||||
use tool_helper::Error;
|
||||
|
||||
fn make_file(name: &str) -> Result<File, Error> {
|
||||
@@ -53,7 +54,7 @@ fn run_main() -> Result<(), Error> {
|
||||
println!("{}", rand_item.0);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
write_image(desc, ImageType::BinCue, PathBuf::from_str("planschi.bin")?)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
Reference in New Issue
Block a user