From 7f9fd1c9d6abca22b58ba2c3bf600afdedcd03e5 Mon Sep 17 00:00:00 2001
From: Deterous <138427222+Deterous@users.noreply.github.com>
Date: Thu, 30 Nov 2023 12:36:24 +1300
Subject: [PATCH] Fix info printing
---
IRDKit/IRDKit.csproj | 2 +-
IRDKit/Program.cs | 31 ++++++++++++++++++++++++++-----
LibIRD/IRD.cs | 2 +-
LibIRD/LibIRD.csproj | 2 +-
LibIRD/ParamSFO.cs | 2 +-
5 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/IRDKit/IRDKit.csproj b/IRDKit/IRDKit.csproj
index 1523d93..9e1e049 100644
--- a/IRDKit/IRDKit.csproj
+++ b/IRDKit/IRDKit.csproj
@@ -10,7 +10,7 @@
win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64
latest
true
- 0.2.0
+ 0.2.1
Deterous
diff --git a/IRDKit/Program.cs b/IRDKit/Program.cs
index e2f0d6d..93f8c0a 100644
--- a/IRDKit/Program.cs
+++ b/IRDKit/Program.cs
@@ -126,7 +126,13 @@ namespace IRDKit
// Create new ISO reader
CDReader reader = new(fs, true, true);
- File.WriteAllText(opt.OutPath, "{\n");
+ if (opt.Json)
+ {
+ if (opt.OutPath != null)
+ File.WriteAllText(opt.OutPath, "{\n");
+ else
+ Console.WriteLine('{');
+ }
// Write PS3_DISC.SFB info
using (DiscUtils.Streams.SparseStream s = reader.OpenFile("PS3_DISC.SFB", FileMode.Open, FileAccess.Read))
@@ -136,9 +142,15 @@ namespace IRDKit
PS3_DiscSFB ps3_DiscSFB = new(s);
if (opt.Json)
{
- File.AppendAllText(opt.OutPath, "\"PS3_DISC.SFB\": ");
+ if (opt.OutPath != null)
+ File.AppendAllText(opt.OutPath, "\"PS3_DISC.SFB\": ");
+ else
+ Console.Write("\"PS3_DISC.SFB\": ");
ps3_DiscSFB.PrintJson(opt.OutPath);
- File.AppendAllText(opt.OutPath, ",");
+ if (opt.OutPath != null)
+ File.AppendAllText(opt.OutPath, ",\n");
+ else
+ Console.WriteLine(',');
}
else
ps3_DiscSFB.Print(opt.OutPath);
@@ -157,7 +169,10 @@ namespace IRDKit
ParamSFO paramSFO = new(s);
if (opt.Json)
{
- File.AppendAllText(opt.OutPath, "\n\"PARAM.SFO\": ");
+ if (opt.OutPath != null)
+ File.AppendAllText(opt.OutPath, "\"PARAM.SFO\": ");
+ else
+ Console.Write("\"PARAM.SFO\": ");
paramSFO.PrintJson(opt.OutPath);
}
else
@@ -169,7 +184,13 @@ namespace IRDKit
}
}
- File.AppendAllText(opt.OutPath, "\n}");
+ if (opt.Json)
+ {
+ if (opt.OutPath != null)
+ File.AppendAllText(opt.OutPath, "\n}\n");
+ else
+ Console.WriteLine("\n}");
+ }
}
else
{
diff --git a/LibIRD/IRD.cs b/LibIRD/IRD.cs
index d010891..f5ae787 100644
--- a/LibIRD/IRD.cs
+++ b/LibIRD/IRD.cs
@@ -1334,7 +1334,7 @@ namespace LibIRD
json.AppendLine($" \"Extra Config\": \"{ExtraConfig:X4}\",");
if (Attachments != 0x0000)
json.AppendLine($" \"Attachments\": \"{Attachments:X4}\",");
- json.AppendLine($" \"Unique ID\": \"{UID:X8}");
+ json.AppendLine($" \"Unique ID\": \"{UID:X8}\",");
json.AppendLine($" \"Data 1 Key\": \"{Convert.ToHexString(Data1Key)}\",");
json.AppendLine($" \"Data 2 Key\": \"{Convert.ToHexString(Data2Key)}\",");
json.AppendLine($" \"PIC\": \"{Convert.ToHexString(PIC)}\"");
diff --git a/LibIRD/LibIRD.csproj b/LibIRD/LibIRD.csproj
index d9f6355..7c35bb0 100644
--- a/LibIRD/LibIRD.csproj
+++ b/LibIRD/LibIRD.csproj
@@ -6,7 +6,7 @@
win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64
latest
true
- 0.2.0
+ 0.2.1
Deterous
diff --git a/LibIRD/ParamSFO.cs b/LibIRD/ParamSFO.cs
index 722be2d..28fbc13 100644
--- a/LibIRD/ParamSFO.cs
+++ b/LibIRD/ParamSFO.cs
@@ -132,7 +132,7 @@ namespace LibIRD
// Build string from parameters
StringBuilder printText = new();
printText.AppendLine("PARAM.SFO Contents:");
- printText.AppendLine("====================");
+ printText.AppendLine("===================");
// Loop through all parameters in PARAM.SFO
foreach (KeyValuePair field in Field)