From 99013e3448df4ea9bcb7ec59134b6ea9d2e7f3ed Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 30 Oct 2020 21:14:07 -0700 Subject: [PATCH] Separate out archive and non-archive in code --- BurnOutSharp/ProtectionFind.cs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/BurnOutSharp/ProtectionFind.cs b/BurnOutSharp/ProtectionFind.cs index 3cf45921..fd683979 100644 --- a/BurnOutSharp/ProtectionFind.cs +++ b/BurnOutSharp/ProtectionFind.cs @@ -416,6 +416,20 @@ namespace BurnOutSharp // Files can be protected in multiple ways List protections = new List(); + #region Non-Archive Formats + + // Executable + if (Executable.ShouldScan(magic)) + protections.AddRange(Executable.Scan(stream, file, includePosition)); + + // Text-based files + if (Textfile.ShouldScan(magic, extension)) + protections.AddRange(Textfile.Scan(stream, includePosition)); + + #endregion + + #region Archive Formats + // 7-Zip archive if (SevenZip.ShouldScan(magic)) protections.AddRange(SevenZip.Scan(stream, includePosition)); @@ -428,10 +442,6 @@ namespace BurnOutSharp if (BZip2.ShouldScan(magic)) protections.AddRange(BZip2.Scan(stream, includePosition)); - // Executable - if (Executable.ShouldScan(magic)) - protections.AddRange(Executable.Scan(stream, file, includePosition)); - // GZIP if (GZIP.ShouldScan(magic)) protections.AddRange(GZIP.Scan(stream, includePosition)); @@ -464,10 +474,6 @@ namespace BurnOutSharp if (TapeArchive.ShouldScan(magic)) protections.AddRange(TapeArchive.Scan(stream, includePosition)); - // Text-based files - if (Textfile.ShouldScan(magic, extension)) - protections.AddRange(Textfile.Scan(stream, includePosition)); - // Valve archive formats if (file != null && Valve.ShouldScan(magic)) protections.AddRange(Valve.Scan(file, includePosition)); @@ -476,6 +482,8 @@ namespace BurnOutSharp if (XZ.ShouldScan(magic)) protections.AddRange(XZ.Scan(stream, includePosition)); + #endregion + // Return blank if nothing found, or comma-separated list of protections if (protections.Count() == 0) return string.Empty;