mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-19 17:36:50 +00:00
Add support for reading SQDB files
This commit is contained in:
parent
4291d0ae06
commit
f307e48a0c
3 changed files with 65 additions and 0 deletions
|
@ -168,3 +168,6 @@ pub mod existing_dirs;
|
|||
|
||||
/// Reading patch lists
|
||||
pub mod patchlist;
|
||||
|
||||
/// Reading SQDB files
|
||||
pub mod sqdb;
|
||||
|
|
60
src/sqdb.rs
Normal file
60
src/sqdb.rs
Normal file
|
@ -0,0 +1,60 @@
|
|||
// SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
use std::io::Cursor;
|
||||
|
||||
use crate::common_file_operations::read_string;
|
||||
use crate::common_file_operations::write_string;
|
||||
use crate::sqpack::SqPackHeader;
|
||||
use crate::ByteSpan;
|
||||
use binrw::helpers::until_eof;
|
||||
use binrw::BinRead;
|
||||
use binrw::binrw;
|
||||
|
||||
#[binrw]
|
||||
#[derive(Debug)]
|
||||
pub struct SQDBHeader {
|
||||
size: u32,
|
||||
#[br(pad_after = 1016)] // nothing
|
||||
unk: u32,
|
||||
}
|
||||
|
||||
// 264 bytes
|
||||
#[binrw]
|
||||
#[derive(Debug)]
|
||||
pub struct SQDBEntry {
|
||||
#[br(pad_before = 4)] // 4 empty bytes
|
||||
offset: u32, // TODO: just a guess, offset into what?
|
||||
#[br(pad_after = 4)] // 4 more empty bytes
|
||||
size: u32, // TODO: also a guess
|
||||
|
||||
// Corresponds to SplitPath hash
|
||||
filename_hash: u32,
|
||||
path_hash: u32,
|
||||
|
||||
// TODO: this is terrible, just read until string nul terminator
|
||||
#[br(count = 240)]
|
||||
#[br(map = read_string)]
|
||||
#[bw(map = write_string)]
|
||||
path: String,
|
||||
}
|
||||
|
||||
#[binrw]
|
||||
#[derive(Debug)]
|
||||
#[brw(little)]
|
||||
pub struct SQDB {
|
||||
sqpack_header: SqPackHeader,
|
||||
|
||||
header: SQDBHeader,
|
||||
|
||||
#[br(parse_with = until_eof)]
|
||||
entries: Vec<SQDBEntry>
|
||||
}
|
||||
|
||||
impl SQDB {
|
||||
/// Reads an existing SQDB file
|
||||
pub fn from_existing(buffer: ByteSpan) -> Option<Self> {
|
||||
let mut cursor = Cursor::new(buffer);
|
||||
SQDB::read(&mut cursor).ok()
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ use crate::dat::{BlockHeader, CompressionMode};
|
|||
/// The type of this SqPack file.
|
||||
#[binrw]
|
||||
#[brw(repr = u8)]
|
||||
#[derive(Debug)]
|
||||
enum SqPackFileType {
|
||||
/// FFXIV Explorer says "SQDB", whatever that is.
|
||||
SQDB = 0x0,
|
||||
|
@ -23,6 +24,7 @@ enum SqPackFileType {
|
|||
|
||||
#[binrw]
|
||||
#[brw(magic = b"SqPack\0\0")]
|
||||
#[derive(Debug)]
|
||||
pub struct SqPackHeader {
|
||||
#[brw(pad_size_to = 4)]
|
||||
platform_id: Platform,
|
||||
|
|
Loading…
Add table
Reference in a new issue