Skip to content

Commit

Permalink
add a separate binary to debug GDFX parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
iliazeus committed May 2, 2023
1 parent 4cee5ce commit 80e6f43
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
52 changes: 52 additions & 0 deletions src/bin/debug_list_files.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#![feature(fs_try_exists)]

use std::io::{BufReader, Read, Seek};

use std::fs::File;
use std::path::{Path, PathBuf};

use anyhow::{Context, Error};

use clap::{command, Parser};

use iso2god::iso;

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(color = clap::ColorChoice::Never)]
struct Cli {
/// Xbox 360 ISO file to convert
source_iso: PathBuf,
}

fn main() -> Result<(), Error> {
let args = Cli::parse();

println!("extracting ISO metadata");

let source_iso_file = open_file_for_buffered_reading(&args.source_iso)
.context("error opening source ISO file")?;

let source_iso = iso::IsoReader::read(BufReader::new(source_iso_file))
.context("error reading source ISO")?;

print_dir(String::new(), &source_iso.directory_table);

Ok(())
}

fn open_file_for_buffered_reading(path: &Path) -> Result<impl Read + Seek, Error> {
let file = File::options().read(true).open(path)?;
let file = BufReader::with_capacity(8 * 1024 * 1024, file);
Ok(file)
}

fn print_dir(path: String, dir: &iso::DirectoryTable) {
for entry in dir.entries.iter() {
if let Some(subdir) = &entry.subdirectory {
print_dir(path.clone() + "/" + &entry.name, subdir);
} else {
println!("{:9} {}/{}", entry.size, path, entry.name);
}
}
}
4 changes: 2 additions & 2 deletions src/iso/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ pub mod directory_table;
pub mod iso_type;
pub mod volume_descriptor;

use directory_table::*;
use volume_descriptor::*;
pub use directory_table::*;
pub use volume_descriptor::*;

pub const SECTOR_SIZE: u64 = 0x800;

Expand Down

0 comments on commit 80e6f43

Please sign in to comment.