Skip to content

Commit

Permalink
Add find_offset function
Browse files Browse the repository at this point in the history
Currently working around the lack of a good extract() API
  • Loading branch information
redstrate committed May 25, 2024
1 parent c1fb2c5 commit fdf07fd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/gamedata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fdf07fd

Please sign in to comment.