From fdf07fd25534299b7f7dd41e546b53246674371c Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 25 May 2024 10:47:48 -0400 Subject: [PATCH] Add find_offset function Currently working around the lack of a good extract() API --- src/gamedata.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gamedata.rs b/src/gamedata.rs index 9d0f8c5..96e65d7 100755 --- a/src/gamedata.rs +++ b/src/gamedata.rs @@ -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 { + 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