From 51a7fbd85bd92c58f8e4e1dbce56c9290d9f58e6 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 27 Jan 2025 19:33:44 -0700 Subject: [PATCH] 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`. --- src/cmd/dol.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cmd/dol.rs b/src/cmd/dol.rs index 7436bee..66b6ad8 100644 --- a/src/cmd/dol.rs +++ b/src/cmd/dol.rs @@ -59,7 +59,7 @@ use crate::{ split::{is_linker_generated_object, split_obj, update_splits}, 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)] @@ -2180,12 +2180,18 @@ pub fn find_object_base(config: &ProjectConfig) -> Result { }; if is_file { 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))?; - if let Some(format) = format { - file.rewind()?; - let fs = open_fs(file, ArchiveKind::Disc(format))?; - return Ok(ObjectBase::Vfs(path, fs)); + match format { + FileFormat::Archive(ArchiveKind::Disc(format)) => { + let fs = open_fs(file, ArchiveKind::Disc(format))?; + return Ok(ObjectBase::Vfs(path, fs)); + } + FileFormat::Archive(ArchiveKind::Wad) => { + let fs = open_fs(file, ArchiveKind::Wad)?; + return Ok(ObjectBase::Vfs(path, fs)); + } + _ => {} } } }