Skip to content

Commit

Permalink
Add WAD support to object_base
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
encounter committed Jan 28, 2025
1 parent a6c7001 commit 51a7fbd
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/cmd/dol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -2180,12 +2180,18 @@ pub fn find_object_base(config: &ProjectConfig) -> Result<ObjectBase> {
};
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));
}
_ => {}
}
}
}
Expand Down

0 comments on commit 51a7fbd

Please sign in to comment.