diff --git a/BurnOutSharp.Wrappers/WrapperBase.cs b/BurnOutSharp.Wrappers/WrapperBase.cs
index d5a94188..c6488214 100644
--- a/BurnOutSharp.Wrappers/WrapperBase.cs
+++ b/BurnOutSharp.Wrappers/WrapperBase.cs
@@ -43,7 +43,7 @@ namespace BurnOutSharp.Wrappers
{
get
{
- var serializer = new System.Text.Json.JsonSerializerOptions { IncludeFields = true };
+ var serializer = new System.Text.Json.JsonSerializerOptions { IncludeFields = true, WriteIndented = true };
serializer.Converters.Add(new ConcreteAbstractSerializer());
serializer.Converters.Add(new ConcreteInterfaceSerializer());
serializer.Converters.Add(new System.Text.Json.Serialization.JsonStringEnumConverter());
diff --git a/Test/Printer.cs b/Test/Printer.cs
index b2c2f7b5..4d8f322c 100644
--- a/Test/Printer.cs
+++ b/Test/Printer.cs
@@ -15,21 +15,22 @@ namespace Test
///
/// File or directory path
/// Enable JSON output, if supported
+ /// Output directory path
/// Enable debug output
- public static void PrintPathInfo(string path, bool json, bool debug)
+ public static void PrintPathInfo(string path, bool json, string outputDirectory, bool debug)
{
Console.WriteLine($"Checking possible path: {path}");
// Check if the file or directory exists
if (File.Exists(path))
{
- PrintFileInfo(path, json, debug);
+ PrintFileInfo(path, json, outputDirectory, debug);
}
else if (Directory.Exists(path))
{
foreach (string file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories))
{
- PrintFileInfo(file, json, debug);
+ PrintFileInfo(file, json, outputDirectory, debug);
}
}
else
@@ -41,7 +42,7 @@ namespace Test
///
/// Print information for a single file, if possible
///
- private static void PrintFileInfo(string file, bool json, bool debug)
+ private static void PrintFileInfo(string file, bool json, string outputDirectory, bool debug)
{
Console.WriteLine($"Attempting to print info for {file}");
@@ -252,15 +253,49 @@ namespace Test
// If we have the JSON flag
if (json)
{
+ // Create the output data
string serializedData = wrapper.ExportJSON();
Console.WriteLine(serializedData);
+
+ // Create the output filename
+ string filename = $"info-{DateTime.Now:yyyy-MM-dd_HHmmss}.json";
+
+ // If we have an output directory
+ if (!string.IsNullOrWhiteSpace(outputDirectory))
+ {
+ Directory.CreateDirectory(outputDirectory);
+ filename = Path.Combine(outputDirectory, filename);
+ }
+
+ // Write the output data
+ using (var sw = new StreamWriter(File.OpenWrite(filename)))
+ {
+ sw.WriteLine(serializedData);
+ }
}
#endif
// If we don't have the JSON flag
if (!json)
{
+ // Create the output data
StringBuilder builder = wrapper.PrettyPrint();
Console.WriteLine(builder);
+
+ // Create the output filename
+ string filename = $"info-{DateTime.Now:yyyy-MM-dd_HHmmss}.txt";
+
+ // If we have an output directory
+ if (!string.IsNullOrWhiteSpace(outputDirectory))
+ {
+ Directory.CreateDirectory(outputDirectory);
+ filename = Path.Combine(outputDirectory, filename);
+ }
+
+ // Write the output data
+ using (var sw = new StreamWriter(File.OpenWrite(filename)))
+ {
+ sw.WriteLine(builder.ToString());
+ }
}
}
}
diff --git a/Test/Program.cs b/Test/Program.cs
index af9be401..df49a103 100644
--- a/Test/Program.cs
+++ b/Test/Program.cs
@@ -139,7 +139,7 @@ namespace Test
foreach (string inputPath in inputPaths)
{
if (info)
- Printer.PrintPathInfo(inputPath, json, debug);
+ Printer.PrintPathInfo(inputPath, json, outputPath, debug);
else if (extract)
Extractor.ExtractPath(inputPath, outputPath);
else
@@ -170,8 +170,8 @@ namespace Test
#if NET6_0_OR_GREATER
Console.WriteLine("-j, --json Print executable info as JSON");
#endif
- Console.WriteLine("-x, --extract Extract archive formats");
- Console.WriteLine("-o, --outdir [PATH] Set output path for extraction (REQUIRED)");
+ Console.WriteLine("-x, --extract Extract archive formats (Requires -o)");
+ Console.WriteLine("-o, --outdir [PATH] Set output path for information and extraction");
}
}
}
diff --git a/Test/Protector.cs b/Test/Protector.cs
index 18573840..59c66536 100644
--- a/Test/Protector.cs
+++ b/Test/Protector.cs
@@ -29,7 +29,7 @@ namespace Test
}
catch (Exception ex)
{
- using (StreamWriter sw = new StreamWriter(File.OpenWrite($"{DateTime.Now:yyyy-MM-dd_HHmmss}-exception.txt")))
+ using (StreamWriter sw = new StreamWriter(File.OpenWrite($"exception-{DateTime.Now:yyyy-MM-dd_HHmmss}.txt")))
{
sw.WriteLine(ex);
}
@@ -49,7 +49,7 @@ namespace Test
return;
}
- using (var sw = new StreamWriter(File.OpenWrite($"{DateTime.Now:yyyy-MM-dd_HHmmss}.txt")))
+ using (var sw = new StreamWriter(File.OpenWrite($"protection-{DateTime.Now:yyyy-MM-dd_HHmmss}.txt")))
{
foreach (string key in protections.Keys.OrderBy(k => k))
{