Skip to main content

source_fs/
traits.rs

1use std::path::Path;
2
3/// Represents a loaded VPK or generic pack file archive.
4pub trait PackFile {
5    /// Opens a pack file from the given physical path.
6    fn open<P: AsRef<Path>>(path: P) -> Option<Self>
7    where
8        Self: Sized;
9
10    /// Checks if a given file entry exists within the pack file.
11    fn has_entry(&self, path: &str) -> bool;
12
13    /// Reads the specified entry's binary data from the pack file.
14    fn read_entry(&self, path: &str) -> Option<Vec<u8>>;
15}
16
17/// Provides parsing capabilities for `gameinfo.txt` to extract search paths.
18pub trait GameInfoProvider {
19    /// Parses the given `gameinfo.txt` file and returns a list of search paths.
20    /// The return value is a list of tuples: `(search_path_id, physical_path)`.
21    fn get_search_paths<P: AsRef<Path>>(path: P) -> Option<Vec<(String, String)>>;
22}