mirror of
https://github.com/encounter/decomp-toolkit.git
synced 2025-12-16 08:27:02 +00:00
Load objects from disc image & vfs module
Revamps support for container paths and centralizes logic into a VFS (virtual file system) module. The new VFS architecture supports disc images and any layer of nesting. For example, the following command works: `dtk dol info 'Interactive Multi-Game Demo Disc - July 2002 (USA).rvz:files/zz_StarFox051702_e3.tgc:files/default.dol'` This opens a TGC file inside an RVZ disc image, then reads `default.dol` in the FST. Another example: `dtk rel info 'Legend of Zelda, The - The Wind Waker (USA).rvz:files/RELS.arc:mmem/f_pc_profile_lst.rel'` This opens a RARC archive inside an RVZ disc image, loads the Yaz0-compressed REL and decompresses it on the fly. This all operates in memory with minimal overhead, with no need to extract temporary files. Supported container formats: - Disc images (ISO/GCM, WIA/RVZ, WBFS, CISO, NFS, GCZ, TGC) - RARC/SZS and U8 (.arc) Supported compression formats: - Yaz0 (SZS) - Yay0 (SZP) - NLZSS (.lz) Additionally, projects can utilize a new configuration key `object_base`: ``` object: orig/GZLE01/sys/main.dol modules: - object: orig/GZLE01/files/RELS.arc:rels/mmem/f_pc_profile_lst.rel ``` becomes ``` object_base: orig/GZLE01 object: sys/main.dol modules: - object: files/RELS.arc:mmem/f_pc_profile_lst.rel ``` When loading the objects, decomp-toolkit will automatically check the `object_base` directory for any disc images. (They can be named anything, but must be in the folder root) If one is found, all objects will be fetched from the disc image itself, rather than having to extract the files manually. While still a work in progress, two new `vfs` commands were added: `vfs ls` and `vfs cp`. These commands are very barebones currently, but allow listing directory contents and extracting files from decomp-toolkit's vfs representation: ``` ❯ dtk vfs ls disc.rvz: files sys ❯ dtk vfs ls disc.rvz:sys boot.bin bi2.bin apploader.bin fst.bin main.dol ❯ dtk vfs cp disc.rvz:sys/main.dol . ```
This commit is contained in:
@@ -3,10 +3,13 @@ use std::{fs, path::PathBuf};
|
||||
use anyhow::{Context, Result};
|
||||
use argp::FromArgs;
|
||||
|
||||
use crate::util::{
|
||||
file::{map_file_basic, process_rsp},
|
||||
ncompress::{compress_yay0, decompress_yay0},
|
||||
IntoCow, ToCow,
|
||||
use crate::{
|
||||
util::{
|
||||
file::process_rsp,
|
||||
ncompress::{compress_yay0, decompress_yay0},
|
||||
IntoCow, ToCow,
|
||||
},
|
||||
vfs::open_path,
|
||||
};
|
||||
|
||||
#[derive(FromArgs, PartialEq, Debug)]
|
||||
@@ -62,8 +65,8 @@ fn compress(args: CompressArgs) -> Result<()> {
|
||||
let single_file = files.len() == 1;
|
||||
for path in files {
|
||||
let data = {
|
||||
let file = map_file_basic(&path)?;
|
||||
compress_yay0(file.as_slice())
|
||||
let mut file = open_path(&path, false)?;
|
||||
compress_yay0(file.map()?)
|
||||
};
|
||||
let out_path = if let Some(output) = &args.output {
|
||||
if single_file {
|
||||
@@ -85,8 +88,8 @@ fn decompress(args: DecompressArgs) -> Result<()> {
|
||||
let single_file = files.len() == 1;
|
||||
for path in files {
|
||||
let data = {
|
||||
let file = map_file_basic(&path)?;
|
||||
decompress_yay0(file.as_slice())
|
||||
let mut file = open_path(&path, true)?;
|
||||
decompress_yay0(file.map()?)
|
||||
.with_context(|| format!("Failed to decompress '{}' using Yay0", path.display()))?
|
||||
};
|
||||
let out_path = if let Some(output) = &args.output {
|
||||
|
||||
Reference in New Issue
Block a user