From 0159c41e20e2eda135ad0e99fbca2ae5cfad3d18 Mon Sep 17 00:00:00 2001 From: ToaHartor Date: Thu, 19 May 2022 23:44:33 +0200 Subject: [PATCH] More printing --- src/FileTypes/USM.cs | 1 + src/Program.cs | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/FileTypes/USM.cs b/src/FileTypes/USM.cs index 1fd8904..63534fb 100644 --- a/src/FileTypes/USM.cs +++ b/src/FileTypes/USM.cs @@ -29,6 +29,7 @@ public USM(string filename, byte[] key1, byte[] key2) _filename = Path.GetFileName(filename); _key1 = key1; _key2 = key2; + Console.WriteLine($"key1={Convert.ToHexString(_key1)} key2={Convert.ToHexString(_key2)}"); InitMask(key1, key2); } private void InitMask(byte[] key1, byte[] key2) diff --git a/src/Program.cs b/src/Program.cs index 61b786d..beda2b9 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.CommandLine; +using System.CommandLine; using CRIDemuxer.FileTypes; namespace CRIDemuxer @@ -38,7 +33,7 @@ private static async Task Main(string[] args) name: "-b", description: "4 higher bytes of the key"); - var rootCommand = new RootCommand("Sample app for System.CommandLine"); + var rootCommand = new RootCommand("An .usm extraction tool for GI."); rootCommand.AddGlobalOption(outputFolderOption); @@ -91,6 +86,8 @@ private static async Task DemuxUsmCommand(FileInfo file, string key1, string key { if (file == null) throw new ArgumentNullException("No file provided."); if (!file.Exists) throw new ArgumentException("File {0} does not exist.", file.Name); + if (!file.Name.EndsWith(".usm")) + throw new ArgumentException($"File {file.Name} provided isn't a .usm file."); if (key1!=null && key2!= null && (key1.Length != 8 || key2.Length != 8)) throw new ArgumentException("Keys are invalid."); string outputArg = (output == null) ? file.Directory.FullName @@ -125,7 +122,7 @@ private static async Task ConvertHcaCommand(FileSystemInfo input, DirectoryInfo? { case FileInfo f: // TODO add keys :shrug: - if (f.Name.EndsWith(".hca")) throw new ArgumentException("File provided is not a .hca file."); + if (!f.Name.EndsWith(".hca")) throw new ArgumentException("File provided is not a .hca file."); HCA file = new(f.FullName); file.ConvertToWAV(outputArg); break;