Alphabetical order, key file path

This commit is contained in:
Deterous
2024-02-08 09:38:46 +09:00
parent 6af41a9bb3
commit cf19596ea7
+14 -7
View File
@@ -159,11 +159,13 @@ namespace IRDKit
} }
// Determine output IRD folder // Determine output IRD folder
string outputPath = Path.GetDirectoryName(opt.IRDPath); string outputPath = opt.IRDPath;
if (File.Exists(opt.IRDPath))
outputPath = Path.GetDirectoryName(opt.IRDPath);
// Create an IRD file for all ISO files found // Create an IRD file for all ISO files found
foreach (string file in isoFiles) foreach (string file in isoFiles.OrderBy(x => x))
ISO2IRD(file, irdPath: outputPath, verbose: opt.Verbose); ISO2IRD(file, irdPath: outputPath, keyPath: opt.KeyFile, verbose: opt.Verbose);
} }
else else
{ {
@@ -719,14 +721,19 @@ namespace IRDKit
{ {
try try
{ {
// If key directory was given, append filename and .key
if (Directory.Exists(keyPath))
{
keyPath = Path.Combine(keyPath, Path.ChangeExtension(Path.GetFileName(isoPath), ".key"));
}
// Read key from .key file // Read key from .key file
byte[] discKey = File.ReadAllBytes(keyPath); byte[] discKey = File.ReadAllBytes(keyPath);
if (discKey == null || discKey.Length != 16) if (discKey == null || discKey.Length != 16)
Console.Error.WriteLine($"{hexKey} is not a valid key, detecting key automatically..."); Console.Error.WriteLine($"{hexKey} is not a valid key, detecting key automatically...");
else else
{ {
IRD ird1 = new ReIRD(isoPath, discKey, layerbreak);
Console.WriteLine($"Creating {irdPath} with Key: {Convert.ToHexString(discKey)}"); Console.WriteLine($"Creating {irdPath} with Key: {Convert.ToHexString(discKey)}");
IRD ird1 = new ReIRD(isoPath, discKey, layerbreak);
ird1.Write(irdPath); ird1.Write(irdPath);
if (verbose) if (verbose)
ird1.Print(); ird1.Print();
@@ -783,8 +790,8 @@ namespace IRDKit
Console.Error.WriteLine($"{hexKey} is not a valid key, detecting key automatically..."); Console.Error.WriteLine($"{hexKey} is not a valid key, detecting key automatically...");
else else
{ {
IRD ird1 = new ReIRD(isoPath, discKey, layerbreak);
Console.WriteLine($"Creating {irdPath} with Key: {Convert.ToHexString(discKey)}"); Console.WriteLine($"Creating {irdPath} with Key: {Convert.ToHexString(discKey)}");
IRD ird1 = new ReIRD(isoPath, discKey, layerbreak);
ird1.Write(irdPath); ird1.Write(irdPath);
if (verbose) if (verbose)
ird1.Print(); ird1.Print();
@@ -811,8 +818,8 @@ namespace IRDKit
// Found .getkey.log file, check it is valid // Found .getkey.log file, check it is valid
try try
{ {
Console.WriteLine($"Creating {irdPath} with key from: {getKeyLog}"); Console.WriteLine($"Creating {irdPath} with key from: {logfilePath}");
IRD ird1 = new ReIRD(isoPath, getKeyLog); IRD ird1 = new ReIRD(isoPath, logfilePath);
ird1.Write(irdPath); ird1.Write(irdPath);
if (verbose) if (verbose)
ird1.Print(); ird1.Print();