Skip to content

Commit bee4570

Browse files
committed
Always check for extracted files in object resolution
Fixes an issue where extracted files would not be found after removing the disc image from the orig dir.
1 parent 18bd608 commit bee4570

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "decomp-toolkit"
33
description = "Yet another GameCube/Wii decompilation toolkit."
44
authors = ["Luke Street <[email protected]>"]
55
license = "MIT OR Apache-2.0"
6-
version = "1.1.2"
6+
version = "1.1.3"
77
edition = "2021"
88
publish = false
99
repository = "https://github.com/encounter/decomp-toolkit"

src/cmd/dol.rs

+17-7
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ fn split(args: SplitArgs) -> Result<()> {
11161116
if config.extract_objects && matches!(object_base, ObjectBase::Vfs(..)) {
11171117
// Extract files from the VFS into the object base directory
11181118
let target_dir = extract_objects(&config, &object_base)?;
1119-
object_base = ObjectBase::Extracted(target_dir);
1119+
object_base = ObjectBase::Directory(target_dir);
11201120
}
11211121

11221122
for module_config in config.modules.iter_mut() {
@@ -2015,25 +2015,36 @@ fn apply_add_relocations(obj: &mut ObjInfo, relocations: &[AddRelocationConfig])
20152015
pub enum ObjectBase {
20162016
None,
20172017
Directory(Utf8NativePathBuf),
2018-
Extracted(Utf8NativePathBuf),
20192018
Vfs(Utf8NativePathBuf, Box<dyn Vfs + Send + Sync>),
20202019
}
20212020

20222021
impl ObjectBase {
20232022
pub fn join(&self, path: &Utf8UnixPath) -> Utf8NativePathBuf {
20242023
match self {
20252024
ObjectBase::None => path.with_encoding(),
2026-
ObjectBase::Directory(base) => base.join(path.with_encoding()),
2027-
ObjectBase::Extracted(base) => extracted_path(base, path),
2025+
ObjectBase::Directory(base) => {
2026+
// If the extracted file exists, use it directly
2027+
let extracted = extracted_path(base, path);
2028+
if fs::exists(&extracted).unwrap_or(false) {
2029+
return extracted;
2030+
}
2031+
base.join(path.with_encoding())
2032+
}
20282033
ObjectBase::Vfs(base, _) => Utf8NativePathBuf::from(format!("{}:{}", base, path)),
20292034
}
20302035
}
20312036

20322037
pub fn open(&self, path: &Utf8UnixPath) -> Result<Box<dyn VfsFile>> {
20332038
match self {
20342039
ObjectBase::None => open_file(&path.with_encoding(), true),
2035-
ObjectBase::Directory(base) => open_file(&base.join(path.with_encoding()), true),
2036-
ObjectBase::Extracted(base) => open_file(&extracted_path(base, path), true),
2040+
ObjectBase::Directory(base) => {
2041+
// If the extracted file exists, use it directly
2042+
let extracted = extracted_path(base, path);
2043+
if fs::exists(&extracted).unwrap_or(false) {
2044+
return open_file(&extracted, true);
2045+
}
2046+
open_file(&base.join(path.with_encoding()), true)
2047+
}
20372048
ObjectBase::Vfs(vfs_path, vfs) => {
20382049
open_file_with_fs(vfs.clone(), &path.with_encoding(), true)
20392050
.with_context(|| format!("Using disc image {}", vfs_path))
@@ -2045,7 +2056,6 @@ impl ObjectBase {
20452056
match self {
20462057
ObjectBase::None => Utf8NativePath::new(""),
20472058
ObjectBase::Directory(base) => base,
2048-
ObjectBase::Extracted(base) => base,
20492059
ObjectBase::Vfs(base, _) => base,
20502060
}
20512061
}

0 commit comments

Comments
 (0)