1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-20 11:47:46 +00:00

Add find_offset function

Currently working around the lack of a good extract() API
This commit is contained in:
Joshua Goins 2024-05-25 10:47:48 -04:00
parent c1fb2c5fa7
commit fdf07fd255

View file

@ -193,6 +193,17 @@ impl GameData {
}
}
/// Finds the offset inside of the DAT file for `path`.
pub fn find_offset(&mut self, path: &str) -> Option<u32> {
let slice = self.find_entry(path);
match slice {
Some((entry, chunk)) => {
Some(entry.offset)
}
None => None,
}
}
/// Parses a path structure and spits out the corresponding category and repository.
fn parse_repository_category(&self, path: &str) -> Option<(&Repository, Category)> {
let tokens: Vec<&str> = path.split('/').collect(); // TODO: use split_once here