Files
BinaryObjectScanner/Test/Program.cs
Matt Nadareski 01451d7009 A bit of cleanup
2020-11-01 16:01:45 -08:00

60 lines
1.8 KiB
C#

using System;
using System.IO;
using System.Linq;
using BurnOutSharp;
namespace Test
{
class Program
{
static void Main(string[] args)
{
// Create progress indicator
var p = new Progress<FileProtection>();
p.ProgressChanged += Changed;
// Create scanner to be shared
var scanner = new Scanner(p)
{
IncludePosition = true,
ScanAllFiles = false,
ScanArchives = true,
ScanPackers = true,
};
foreach (string arg in args)
{
var protections = scanner.GetProtections(arg);
if (protections != null)
{
using (StreamWriter sw = new StreamWriter(File.OpenWrite($"{DateTime.Now:yyyy-MM-dd_HHmmss}.txt")))
{
foreach (string key in protections.Keys)
{
// Skip over files with no protection
if (protections[key] == null || !protections[key].Any())
continue;
string line = $"{key}: {string.Join(", ", protections[key])}";
Console.WriteLine(line);
sw.WriteLine(line);
}
}
}
else
{
Console.WriteLine($"No protections found for {arg}");
}
}
Console.WriteLine("Press any button to close...");
Console.ReadLine();
}
private static void Changed(object source, FileProtection value)
{
Console.WriteLine($"{value.Percentage * 100:N2}%: {value.Filename} - {value.Protection}");
}
}
}