1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-25 13:57:45 +00:00

Add support for reading the file info format

I revisited this format, and discovered a lot of stuff I did wrong the
first time around when writing libxiv. Now that's fixed!
This commit is contained in:
Joshua Goins 2022-08-06 20:38:15 -04:00
parent 7b2751f57e
commit 5b7cf1d6a3
2 changed files with 43 additions and 1 deletions

39
src/fiin.rs Normal file
View file

@ -0,0 +1,39 @@
use std::ffi::CString;
use std::io::Cursor;
use binrw::binread;
use crate::gamedata::MemoryBuffer;
use binrw::BinRead;
#[binread]
#[br(magic = b"FileInfo")]
#[derive(Debug)]
pub struct FileInfo {
#[br(pad_before = 20)]
#[br(temp)]
entries_size : i32,
#[br(pad_before = 992)]
#[br(count = entries_size / 96)]
entries : Vec<FIINEntry>
}
#[binread]
#[derive(Debug)]
pub struct FIINEntry {
file_size : i32,
#[br(pad_before = 4)]
#[br(count = 64)]
#[br(map = | x: Vec < u8 > | String::from_utf8(x).unwrap())]
file_name: String,
#[br(count = 24)]
sha1 : Vec<u8>
}
impl FileInfo {
pub fn from_existing(buffer : &MemoryBuffer) -> Option<FileInfo> {
let mut cursor = Cursor::new(buffer);
Some(FileInfo::read(&mut cursor).ok()?)
}
}

View file

@ -52,4 +52,7 @@ pub mod exh;
pub mod exd;
// Reading Havok XML sidecar files.
pub mod skeleton;
pub mod skeleton;
// Reading file into files (FIIN).
pub mod fiin;