diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/iso/fs.rs | 7 | ||||
| -rw-r--r-- | src/iso/loader.rs | 25 | ||||
| -rw-r--r-- | src/iso/mod.rs | 3 | ||||
| -rw-r--r-- | src/main.rs | 13 |
4 files changed, 45 insertions, 3 deletions
diff --git a/src/iso/fs.rs b/src/iso/fs.rs new file mode 100644 index 0000000..1f90851 --- /dev/null +++ b/src/iso/fs.rs @@ -0,0 +1,7 @@ +#[repr(C)] +pub struct FileTableEntry { + flags: u8, + name_offset: u24, // pointer to string table + offset: u32, + length: u32, +} diff --git a/src/iso/loader.rs b/src/iso/loader.rs new file mode 100644 index 0000000..b8c61da --- /dev/null +++ b/src/iso/loader.rs @@ -0,0 +1,25 @@ + +use std::{path::Path}; +use sha2::{Sha256}; +use std::fs::File; +use hex_literal::hex; +use digest_io::HashReader; +use std::io::BufReader; + +pub struct GameIso { + filepath: bool +} + +impl GameIso { + pub fn new<P: AsRef<Path>>(path: P) -> () { + let file = File::open(path).unwrap(); + let reader = BufReader::new(file); + + let mut hasher: HashReader<Sha256, BufReader<File>> = HashReader::<Sha256, BufReader<File>>::new(reader); + hasher.hash_to_end(); + let hash = hasher.finalize(); + let s: String = hash.iter().map(|b| format!("{:02x}", b)).collect(); + + assert!(hash == hex!("a08ad2654831ab298071bdcdf727945efcfdd50d2b0e3512a3d361ee7b18296d")); + } +} diff --git a/src/iso/mod.rs b/src/iso/mod.rs new file mode 100644 index 0000000..2d546d9 --- /dev/null +++ b/src/iso/mod.rs @@ -0,0 +1,3 @@ +mod loader; + +pub use loader::GameIso; diff --git a/src/main.rs b/src/main.rs index 44d0887..573b8db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,20 +1,27 @@ +use std::path::PathBuf; use clap::Parser; #[derive(Parser, Debug)] #[command(version, about, long_about = None)] struct Args { #[arg(short, long)] - volume: f64, + volume: Option<f64>, #[arg(short, long)] - timbre: f64, + timbre: Option<f64>, + + #[arg(long, value_name = "CISO filepath")] + iso_path: PathBuf, } mod phonemes; mod tokenizer; +mod iso; fn main() { - let _args = Args::parse(); + let args = Args::parse(); + + let game = iso::GameIso::new(args.iso_path); println!("Hello, world!"); } |