mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-08 18:06:34 +00:00
Strip out temp paths from results and progress
This commit is contained in:
@@ -97,7 +97,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempPath, includePosition);
|
||||
protections = fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
|
||||
// If temp directory cleanup fails
|
||||
try
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempFile, includePosition);
|
||||
string protection = string.Join("\r\n", fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()));
|
||||
string protection = string.Join("\r\n", fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()));
|
||||
|
||||
// If tempfile cleanup fails
|
||||
try
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempFile, includePosition);
|
||||
string protection = string.Join("\r\n", fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()));
|
||||
string protection = string.Join("\r\n", fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()));
|
||||
|
||||
// If tempfile cleanup fails
|
||||
try
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempPath, includePosition);
|
||||
protections = fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
|
||||
// If temp directory cleanup fails
|
||||
try
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempPath, includePosition);
|
||||
protections = fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
|
||||
// If temp directory cleanup fails
|
||||
try
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempPath, includePosition);
|
||||
protections = fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
|
||||
// If temp directory cleanup fails
|
||||
try
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempPath, includePosition);
|
||||
protections = fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
|
||||
// If temp directory cleanup fails
|
||||
try
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempPath, includePosition);
|
||||
protections = fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
|
||||
// If temp directory cleanup fails
|
||||
try
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempPath, includePosition);
|
||||
protections = fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
|
||||
// If temp directory cleanup fails
|
||||
try
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempPath, includePosition);
|
||||
protections = fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
|
||||
// If temp directory cleanup fails
|
||||
try
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempPath, includePosition);
|
||||
protections = fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
|
||||
// If temp directory cleanup fails
|
||||
try
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace BurnOutSharp.FileType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempFile, includePosition);
|
||||
string protection = string.Join("\r\n", fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()));
|
||||
string protection = string.Join("\r\n", fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()));
|
||||
|
||||
// If tempfile cleanup fails
|
||||
try
|
||||
|
||||
@@ -62,19 +62,28 @@ namespace BurnOutSharp
|
||||
// Checkpoint
|
||||
FileProgress?.Report(new FileProtection(null, 0, null));
|
||||
|
||||
// Temp variables for reporting
|
||||
string tempFilePath = Path.GetTempPath();
|
||||
string tempFilePathWithGuid = Path.Combine(tempFilePath, Guid.NewGuid().ToString());
|
||||
|
||||
// If we have a file
|
||||
if (File.Exists(path))
|
||||
{
|
||||
// Set total
|
||||
Total = 1;
|
||||
|
||||
// Get the reportable file name
|
||||
string reportableFileName = path;
|
||||
if (reportableFileName.StartsWith(tempFilePath))
|
||||
reportableFileName = reportableFileName.Substring(tempFilePathWithGuid.Length);
|
||||
|
||||
// Try using just the file first to get protection info
|
||||
string fileProtection = ScanPath(path, false);
|
||||
if (!string.IsNullOrWhiteSpace(fileProtection))
|
||||
protections[path] = fileProtection;
|
||||
|
||||
// Checkpoint
|
||||
FileProgress?.Report(new FileProtection(path, 1, "Checking file"));
|
||||
FileProgress?.Report(new FileProtection(reportableFileName, 1, "Checking file"));
|
||||
|
||||
// Now check to see if the file contains any additional information
|
||||
string contentProtection = ScanContent(path, includePosition)?.Replace("" + (char)0x00, "");
|
||||
@@ -88,7 +97,7 @@ namespace BurnOutSharp
|
||||
|
||||
// Checkpoint
|
||||
protections.TryGetValue(path, out string fullProtection);
|
||||
FileProgress?.Report(new FileProtection(path, 1, fullProtection ?? string.Empty));
|
||||
FileProgress?.Report(new FileProtection(reportableFileName, 1, fullProtection ?? string.Empty));
|
||||
}
|
||||
// If we have a directory
|
||||
else if (Directory.Exists(path))
|
||||
@@ -113,8 +122,13 @@ namespace BurnOutSharp
|
||||
// Get the current file
|
||||
string file = files.ElementAt(i);
|
||||
|
||||
// Get the reportable file name
|
||||
string reportableFileName = file;
|
||||
if (reportableFileName.StartsWith(tempFilePath))
|
||||
reportableFileName = reportableFileName.Substring(tempFilePathWithGuid.Length);
|
||||
|
||||
// Checkpoint
|
||||
FileProgress?.Report(new FileProtection(file, i / (float)files.Count(), "Checking file"));
|
||||
FileProgress?.Report(new FileProtection(reportableFileName, i / (float)files.Count(), "Checking file"));
|
||||
|
||||
// Try using just the file first to get protection info
|
||||
string fileProtection = ScanPath(file, false);
|
||||
@@ -133,7 +147,7 @@ namespace BurnOutSharp
|
||||
|
||||
// Checkpoint
|
||||
protections.TryGetValue(file, out string fullProtection);
|
||||
FileProgress?.Report(new FileProtection(file, i / (float)files.Count(), fullProtection ?? string.Empty));
|
||||
FileProgress?.Report(new FileProtection(reportableFileName, i / (float)files.Count(), fullProtection ?? string.Empty));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
// Collect and format all found protections
|
||||
var fileProtections = ProtectionFind.Scan(tempPath, includePosition);
|
||||
protections = fileProtections.Select(kvp => kvp.Key + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
protections = fileProtections.Select(kvp => kvp.Key.Substring(tempPath.Length) + ": " + kvp.Value.TrimEnd()).ToList();
|
||||
|
||||
// If temp directory cleanup fails
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user