Info should act like scan

This commit is contained in:
Matt Nadareski
2023-01-13 15:15:30 -08:00
parent 9ddd6cc317
commit 29b999b8ed
2 changed files with 8 additions and 29 deletions

View File

@@ -15,22 +15,21 @@ namespace Test
/// </summary>
/// <param name="path">File or directory path</param>
/// <param name="json">Enable JSON output, if supported</param>
/// <param name="outputDirectory">Output directory path</param>
/// <param name="debug">Enable debug output</param>
public static void PrintPathInfo(string path, bool json, string outputDirectory, bool debug)
public static void PrintPathInfo(string path, bool json, bool debug)
{
Console.WriteLine($"Checking possible path: {path}");
// Check if the file or directory exists
if (File.Exists(path))
{
PrintFileInfo(path, json, outputDirectory, debug);
PrintFileInfo(path, json, debug);
}
else if (Directory.Exists(path))
{
foreach (string file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories))
{
PrintFileInfo(file, json, outputDirectory, debug);
PrintFileInfo(file, json, debug);
}
}
else
@@ -42,7 +41,7 @@ namespace Test
/// <summary>
/// Print information for a single file, if possible
/// </summary>
private static void PrintFileInfo(string file, bool json, string outputDirectory, bool debug)
private static void PrintFileInfo(string file, bool json, bool debug)
{
Console.WriteLine($"Attempting to print info for {file}");
@@ -257,18 +256,8 @@ namespace Test
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)))
using (var sw = new StreamWriter(File.OpenWrite($"info-{DateTime.Now:yyyy-MM-dd_HHmmss}.json")))
{
sw.WriteLine(serializedData);
}
@@ -281,18 +270,8 @@ namespace Test
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)))
using (var sw = new StreamWriter(File.OpenWrite($"info-{DateTime.Now:yyyy-MM-dd_HHmmss}.txt")))
{
sw.WriteLine(builder.ToString());
}

View File

@@ -139,7 +139,7 @@ namespace Test
foreach (string inputPath in inputPaths)
{
if (info)
Printer.PrintPathInfo(inputPath, json, outputPath, debug);
Printer.PrintPathInfo(inputPath, json, debug);
else if (extract)
Extractor.ExtractPath(inputPath, outputPath);
else
@@ -171,7 +171,7 @@ namespace Test
Console.WriteLine("-j, --json Print executable info as JSON");
#endif
Console.WriteLine("-x, --extract Extract archive formats (Requires -o)");
Console.WriteLine("-o, --outdir [PATH] Set output path for information and extraction");
Console.WriteLine("-o, --outdir [PATH] Set output path for extraction (Requires -x)");
}
}
}