Add WAD support to object_base

This allows WAD projects to use the auto-extraction
feature: decomp-toolkit will extract all `object`s
from a disc file or WAD file that exists in the
configured `object_base`.
This commit is contained in:
Luke Street 2025-01-27 19:33:44 -07:00
parent a6c7001a52
commit 51a7fbd85b

View File

@ -59,7 +59,7 @@ use crate::{
split::{is_linker_generated_object, split_obj, update_splits}, split::{is_linker_generated_object, split_obj, update_splits},
IntoCow, ToCow, IntoCow, ToCow,
}, },
vfs::{open_file, open_file_with_fs, open_fs, ArchiveKind, Vfs, VfsFile}, vfs::{detect, open_file, open_file_with_fs, open_fs, ArchiveKind, FileFormat, Vfs, VfsFile},
}; };
#[derive(FromArgs, PartialEq, Debug)] #[derive(FromArgs, PartialEq, Debug)]
@ -2180,12 +2180,18 @@ pub fn find_object_base(config: &ProjectConfig) -> Result<ObjectBase> {
}; };
if is_file { if is_file {
let mut file = open_file(&path, false)?; let mut file = open_file(&path, false)?;
let format = nodtool::nod::Disc::detect(file.as_mut()) let format = detect(file.as_mut())
.with_context(|| format!("Detecting file type for {}", path))?; .with_context(|| format!("Detecting file type for {}", path))?;
if let Some(format) = format { match format {
file.rewind()?; FileFormat::Archive(ArchiveKind::Disc(format)) => {
let fs = open_fs(file, ArchiveKind::Disc(format))?; let fs = open_fs(file, ArchiveKind::Disc(format))?;
return Ok(ObjectBase::Vfs(path, fs)); return Ok(ObjectBase::Vfs(path, fs));
}
FileFormat::Archive(ArchiveKind::Wad) => {
let fs = open_fs(file, ArchiveKind::Wad)?;
return Ok(ObjectBase::Vfs(path, fs));
}
_ => {}
} }
} }
} }