1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-26 22:27:44 +00:00

Add support for writing fiin files

This commit is contained in:
Joshua Goins 2023-09-22 17:44:31 -04:00
parent bbbbb7cd02
commit 9b1927f700

View file

@ -4,7 +4,7 @@
use std::fs::read;
use std::io::Cursor;
use binrw::BinRead;
use binrw::{BinRead, BinWrite};
use binrw::binrw;
use crate::gamedata::MemoryBuffer;
@ -52,6 +52,17 @@ impl FileInfo {
FileInfo::read(&mut cursor).ok()
}
pub fn write_to_buffer(&self) -> Option<MemoryBuffer> {
let mut buffer = MemoryBuffer::new();
{
let mut cursor = Cursor::new(&mut buffer);
self.write(&mut cursor).ok()?;
}
Some(buffer)
}
/// Creates a new FileInfo structure from a list of filenames. These filenames must be present in
/// the current working directory in order to be read properly, since it also generates SHA1
/// hashes.