1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
pub mod entry;
pub mod structs;
pub mod vpk;
pub use crate::vpk::VPK;
use thiserror::Error;
use std::path::Path;
#[derive(Debug, Error)]
pub enum Error {
#[error("Error while trying to read data: {0}")]
ReadError(#[from] std::io::Error),
#[error("Error while trying to read data: {0}")]
BinReadError(#[from] binread::Error),
#[error("Invalid signature, provided file is not a VPK file")]
InvalidSignature,
#[error("Unsupported VPK version({0}), only version 2 and low")]
UnsupportedVersion(u32),
#[error("Mismatched size for hashes section")]
HashSizeMismatch,
#[error("Malformed index encountered while parsing")]
MalformedIndex
}
pub fn from_path(path: &str) -> Result<VPK, Error> {
let path = Path::new(path);
let vpk = VPK::read(&path)?;
Ok(vpk)
}