aboutsummaryrefslogtreecommitdiff
path: root/src/iso
diff options
context:
space:
mode:
Diffstat (limited to 'src/iso')
-rw-r--r--src/iso/fs.rs7
-rw-r--r--src/iso/loader.rs25
-rw-r--r--src/iso/mod.rs3
3 files changed, 35 insertions, 0 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;