bnd: unpacker skeleton

This commit is contained in:
dece 2020-04-23 19:36:23 +02:00
parent a81c28c479
commit 761662e76f
3 changed files with 37 additions and 0 deletions

View file

@ -1,10 +1,12 @@
pub mod name_hashes;
pub mod parsers {
pub mod bhd;
pub mod bnd;
pub mod dcx;
}
pub mod unpackers {
pub mod bhd;
pub mod bnd;
pub mod dcx;
pub mod errors;
}

0
src/parsers/bnd.rs Normal file
View file

View file

@ -0,0 +1,35 @@
use crate::parsers::bnd;
use crate::unpackers::errors::{self as unpackers_errors, UnpackError};
/// Extract BND file contents to disk.
///
/// Wraps around `extract_bnd` to load the BND from disk.
pub fn extract_bnd_file(bnd_path: &str, output_path: &str) -> Result<(), UnpackError> {
let bnd = load_bnd_file(bnd_path)?;
extract_bnd(bnd, output_path)?;
Ok(())
}
/// Extract BND contents to disk.
pub fn extract_bnd(bnd: bnd::Bnd, output_path: &str) -> Result<(), UnpackError> {
//TODO
//let mut output_file = fs::File::create(output_path)?;
//output_file.write_all(&decomp_data)?;
Ok(())
}
/// Load a BND file from disk.
///
/// Wraps around `load_bnd` to load the BND from disk.
pub fn load_bnd_file(bnd_path: &str) -> Result<bnd::Bnd, UnpackError> {
let mut bnd_file = fs::File::open(bnd_path)?;
let file_len = bnd_file.metadata()?.len() as usize;
let mut bnd_data = vec![0u8; file_len];
bnd_file.read_exact(&mut bnd_data)?;
load_bnd(&bnd_data)
}
/// Load a BND file from a bytes slice.
pub fn load_bnd(bnd_data: &[u8]) -> Result<bnd::Bnd, UnpackError> {
Ok(())
}