mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-08 18:06:34 +00:00
Let's try to be fancy
This commit is contained in:
@@ -14,6 +14,11 @@
|
||||
/// </summary>
|
||||
public string? Filename { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of levels deep the file is
|
||||
/// </summary>
|
||||
public int Depth { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Value between 0 and 1 representign the percentage completed
|
||||
/// </summary>
|
||||
@@ -27,6 +32,15 @@
|
||||
public ProtectionProgress(string? filename, float percentage, string? protection)
|
||||
{
|
||||
Filename = filename;
|
||||
Depth = 0;
|
||||
Percentage = percentage;
|
||||
Protection = protection;
|
||||
}
|
||||
|
||||
public ProtectionProgress(string? filename, int depth, float percentage, string? protection)
|
||||
{
|
||||
Filename = filename;
|
||||
Depth = depth;
|
||||
Percentage = percentage;
|
||||
Protection = protection;
|
||||
}
|
||||
|
||||
@@ -114,11 +114,15 @@ namespace BinaryObjectScanner
|
||||
|
||||
// Get the reportable file name
|
||||
string reportableFileName = file;
|
||||
int depth = 0;
|
||||
if (reportableFileName.StartsWith(tempFilePath))
|
||||
reportableFileName = $"--> {reportableFileName.Substring(tempFilePathWithGuid.Length)}";
|
||||
{
|
||||
depth = 1;
|
||||
reportableFileName = reportableFileName.Substring(tempFilePathWithGuid.Length);
|
||||
}
|
||||
|
||||
// Checkpoint
|
||||
_fileProgress?.Report(new ProtectionProgress(reportableFileName, i / (float)files.Count, "Checking file" + (file != reportableFileName ? " from archive" : string.Empty)));
|
||||
_fileProgress?.Report(new ProtectionProgress(reportableFileName, depth, i / (float)files.Count, "Checking file" + (file != reportableFileName ? " from archive" : string.Empty)));
|
||||
|
||||
// Scan for path-detectable protections
|
||||
if (_options.ScanPaths)
|
||||
@@ -138,7 +142,7 @@ namespace BinaryObjectScanner
|
||||
var fullProtection = fullProtectionList != null && fullProtectionList.Count > 0
|
||||
? string.Join(", ", [.. fullProtectionList])
|
||||
: null;
|
||||
_fileProgress?.Report(new ProtectionProgress(reportableFileName, (i + 1) / (float)files.Count, fullProtection ?? string.Empty));
|
||||
_fileProgress?.Report(new ProtectionProgress(reportableFileName, depth, (i + 1) / (float)files.Count, fullProtection ?? string.Empty));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,11 +151,15 @@ namespace BinaryObjectScanner
|
||||
{
|
||||
// Get the reportable file name
|
||||
string reportableFileName = path;
|
||||
int depth = 0;
|
||||
if (reportableFileName.StartsWith(tempFilePath))
|
||||
reportableFileName = $"--> {reportableFileName.Substring(tempFilePathWithGuid.Length)}";
|
||||
{
|
||||
depth = 1;
|
||||
reportableFileName = reportableFileName.Substring(tempFilePathWithGuid.Length);
|
||||
}
|
||||
|
||||
// Checkpoint
|
||||
_fileProgress?.Report(new ProtectionProgress(reportableFileName, 0, "Checking file" + (path != reportableFileName ? " from archive" : string.Empty)));
|
||||
_fileProgress?.Report(new ProtectionProgress(reportableFileName, depth, 0, "Checking file" + (path != reportableFileName ? " from archive" : string.Empty)));
|
||||
|
||||
// Scan for path-detectable protections
|
||||
if (_options.ScanPaths)
|
||||
@@ -171,7 +179,7 @@ namespace BinaryObjectScanner
|
||||
var fullProtection = fullProtectionList != null && fullProtectionList.Count > 0
|
||||
? string.Join(", ", [.. fullProtectionList])
|
||||
: null;
|
||||
_fileProgress?.Report(new ProtectionProgress(reportableFileName, 1, fullProtection ?? string.Empty));
|
||||
_fileProgress?.Report(new ProtectionProgress(reportableFileName, depth, 1, fullProtection ?? string.Empty));
|
||||
}
|
||||
|
||||
// Throw on an invalid path
|
||||
|
||||
@@ -134,7 +134,13 @@ namespace ProtectionScan
|
||||
/// </summary>
|
||||
private static void Changed(object? source, ProtectionProgress value)
|
||||
{
|
||||
Console.WriteLine($"{value.Percentage * 100:N2}%: {value.Filename} - {value.Protection}");
|
||||
string prefix = string.Empty;
|
||||
for (int i = 0; i < value.Depth; i++)
|
||||
{
|
||||
prefix += "--> ";
|
||||
}
|
||||
|
||||
Console.WriteLine($"{prefix}{value.Percentage * 100:N2}%: {value.Filename} - {value.Protection}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user