Strip out temp paths from results and progress

This commit is contained in:
Matt Nadareski
2020-10-28 13:17:26 -07:00
parent cd5f9561bf
commit dfabb1a244
14 changed files with 31 additions and 17 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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));
}
}

View File

@@ -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