1
0
Fork 0
mirror of https://codeberg.org/icewind/vbsp.git synced 2026-06-03 18:54:05 +02:00

add Packfile::has

This commit is contained in:
Robin Appelman 2023-12-19 18:59:19 +01:00
commit 5c7b6e9fbd

View file

@ -476,6 +476,20 @@ impl Packfile {
entry.read_exact(&mut buff)?;
Ok(Some(buff))
}
pub fn has(&self, name: &str) -> BspResult<bool> {
let mut zip = self.zip.lock().unwrap();
let result = match zip.by_name(name) {
Ok(_) => Ok(true),
Err(ZipError::FileNotFound) => {
return Ok(false);
}
Err(e) => {
return Err(e.into());
}
};
result
}
}
fn try_read_enum<Enum, Reader, Error, ErrorFn>(