cIOS building stub, continuing on desktop

This commit is contained in:
2026-03-10 16:38:31 -04:00
parent 449097967c
commit 3f112856e5
3 changed files with 93 additions and 40 deletions

View File

@@ -45,24 +45,10 @@ enum Commands {
/// The path to a TMD, Ticket, or WAD /// The path to a TMD, Ticket, or WAD
input: String, input: String,
}, },
/// Apply patches to an IOS /// Modify an IOS
IosPatch { Ios {
/// The IOS WAD to apply patches to #[command(subcommand)]
input: String, command: title::ios::Commands
#[arg(short, long)]
/// An optional output path; default to overwriting input file if not provided
output: Option<String>,
/// Set a new IOS version (0-65535)
#[arg(short, long)]
version: Option<u16>,
/// Set the slot that this IOS will install into
#[arg(short, long)]
slot: Option<u8>,
/// Set all patched content to be non-shared
#[arg(short, long, action)]
no_shared: bool,
#[command(flatten)]
enabled_patches: title::iospatcher::EnabledPatches,
}, },
/// Compress/decompress data using LZ77 compression /// Compress/decompress data using LZ77 compression
Lz77 { Lz77 {
@@ -137,24 +123,31 @@ fn main() -> Result<()> {
Some(Commands::Info { input }) => { Some(Commands::Info { input }) => {
info::info(input)? info::info(input)?
}, },
Some(Commands::IosPatch { Some(Commands::Ios { command }) => {
input, match command {
output, title::ios::Commands::Cios {
version, base,
slot, map,
no_shared, output,
enabled_patches cios_version,
} modules,
) => { slot,
title::iospatcher::patch_ios( version
input, } => {
output, title::ios::build_cios(base, map, output, cios_version, modules, slot, version)?
version, },
slot, title::ios::Commands::Patch {
no_shared, input,
enabled_patches, output,
)? version,
} slot,
no_shared,
enabled_patches
} => {
title::ios::patch_ios(input, output, version, slot, no_shared, enabled_patches)?
}
}
},
Some(Commands::Lz77 { command }) => { Some(Commands::Lz77 { command }) => {
match command { match command {
archive::lz77::Commands::Compress { input, output } => { archive::lz77::Commands::Compress { input, output } => {

View File

@@ -1,16 +1,62 @@
// title/iospatcher.rs from ruswtii (c) 2025 NinjaCheetah & Contributors // title/ios.rs from ruswtii (c) 2025 NinjaCheetah & Contributors
// https://github.com/NinjaCheetah/rustwii // https://github.com/NinjaCheetah/rustwii
// //
// Code for the iospatcher command in the rustwii CLI. // Code for the IOS patcher and cIOS build commands in the rustwii CLI.
use std::fs; use std::fs;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use clap::Args; use clap::{Args, Subcommand};
use rustwii::title; use rustwii::title;
use rustwii::title::iospatcher; use rustwii::title::iospatcher;
use rustwii::title::tmd::ContentType; use rustwii::title::tmd::ContentType;
#[derive(Subcommand)]
#[command(arg_required_else_help = true)]
pub enum Commands {
/// Build a cIOS from a provided base IOS and map
Cios {
/// The base IOS WAD
base: String,
/// The cIOS map file
map: String,
/// Path for the finished cIOS WAD
output: String,
/// The cIOS version from the map to build
#[arg(short, long)]
cios_version: Option<u16>,
/// Path to the directory containing the cIOS modules (optional, defaults to the current
/// directory)
#[arg(short, long)]
modules: Option<String>,
/// Slot that the cIOS will install to (optional, defaults to 249)
#[arg(short, long)]
slot: Option<u8>,
/// IOS version the cIOS will have (optional, defaults to 65535)
#[arg(short, long)]
version: Option<u16>
},
/// Apply patches to an IOS
Patch {
/// The IOS WAD to apply patches to
input: String,
/// An optional output path; default to overwriting input file if not provided
#[arg(short, long)]
output: Option<String>,
/// Set a new IOS version (0-65535)
#[arg(short, long)]
version: Option<u16>,
/// Set the slot that this IOS will install into
#[arg(short, long)]
slot: Option<u8>,
/// Set all patched content to be non-shared
#[arg(short, long, action)]
no_shared: bool,
#[command(flatten)]
enabled_patches: EnabledPatches,
}
}
#[derive(Args)] #[derive(Args)]
#[clap(next_help_heading = "Patches")] #[clap(next_help_heading = "Patches")]
#[group(multiple = true, required = true)] #[group(multiple = true, required = true)]
@@ -148,3 +194,17 @@ fn set_type_normal(ios: &mut title::Title, index: usize) -> Result<()> {
Ok(()) Ok(())
} }
pub fn build_cios(
base: &str,
map: &str,
output: &str,
cios_version: &Option<u16>,
modules: &Option<String>,
slot: &Option<u8>,
version: &Option<u16>
) -> Result<()> {
todo!();
Ok(())
}

View File

@@ -6,4 +6,4 @@ pub mod nus;
pub mod wad; pub mod wad;
pub mod tmd; pub mod tmd;
mod shared; mod shared;
pub mod iospatcher; pub mod ios;