From 29bd888052a627740422d99dc1470d74ce953564 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 26 Aug 2025 06:53:08 -0400 Subject: [PATCH] Order of operations --- BinaryObjectScanner/FileType/PKZIP.cs | 8 ++++---- BinaryObjectScanner/FileType/RAR.cs | 8 ++++---- BinaryObjectScanner/FileType/SevenZip.cs | 10 +++++----- ExtractionTool/Program.cs | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/BinaryObjectScanner/FileType/PKZIP.cs b/BinaryObjectScanner/FileType/PKZIP.cs index c5717ef8..46046199 100644 --- a/BinaryObjectScanner/FileType/PKZIP.cs +++ b/BinaryObjectScanner/FileType/PKZIP.cs @@ -50,12 +50,12 @@ namespace BinaryObjectScanner.FileType // Find all file parts FileInfo[] parts = [.. ArchiveFactory.GetFileParts(new FileInfo(file))]; - // Try to read the file path if no entries are found - if (zipFile.Entries.Count == 0) + // If there are multiple parts + if (parts.Length > 1) zipFile = ZipArchive.Open(parts, readerOptions); - // If there are multiple parts - else if (parts.Length > 1) + // Try to read the file path if no entries are found + else if (zipFile.Entries.Count == 0) zipFile = ZipArchive.Open(parts, readerOptions); } diff --git a/BinaryObjectScanner/FileType/RAR.cs b/BinaryObjectScanner/FileType/RAR.cs index b1f01fa3..30228a6c 100644 --- a/BinaryObjectScanner/FileType/RAR.cs +++ b/BinaryObjectScanner/FileType/RAR.cs @@ -51,12 +51,12 @@ namespace BinaryObjectScanner.FileType // Find all file parts FileInfo[] parts = [.. ArchiveFactory.GetFileParts(new FileInfo(file))]; - // Try to read the file path if no entries are found - if (rarFile.Entries.Count == 0) + // If there are multiple parts + if (parts.Length > 1) rarFile = RarArchive.Open(parts, readerOptions); - // If there's any multipart items, try reading the file as well - else if (parts.Length > 1) + // Try to read the file path if no entries are found + else if (rarFile.Entries.Count == 0) rarFile = RarArchive.Open(parts, readerOptions); } diff --git a/BinaryObjectScanner/FileType/SevenZip.cs b/BinaryObjectScanner/FileType/SevenZip.cs index 82df1df8..fd25fb3a 100644 --- a/BinaryObjectScanner/FileType/SevenZip.cs +++ b/BinaryObjectScanner/FileType/SevenZip.cs @@ -50,13 +50,13 @@ namespace BinaryObjectScanner.FileType { // Find all file parts FileInfo[] parts = [.. ArchiveFactory.GetFileParts(new FileInfo(file))]; + + // If there are multiple parts + if (parts.Length > 1) + sevenZip = SevenZipArchive.Open(parts, readerOptions); // Try to read the file path if no entries are found - if (sevenZip.Entries.Count == 0) - sevenZip = SevenZipArchive.Open(parts, readerOptions); - - // If there's any multipart items, try reading the file as well - else if (parts.Length > 1) + else if (sevenZip.Entries.Count == 0) sevenZip = SevenZipArchive.Open(parts, readerOptions); } diff --git a/ExtractionTool/Program.cs b/ExtractionTool/Program.cs index 3a27e9aa..3ec7f68a 100644 --- a/ExtractionTool/Program.cs +++ b/ExtractionTool/Program.cs @@ -93,12 +93,12 @@ namespace ExtractionTool // Get the file type WrapperType ft = WrapperFactory.GetFileType(magic, extension); var wrapper = WrapperFactory.CreateWrapper(ft, stream); - if (wrapper == null) - { - Console.WriteLine("Could not determine the file format, skipping..."); - Console.WriteLine(); - return; - } + // if (wrapper == null) + // { + // Console.WriteLine("Could not determine the file format, skipping..."); + // Console.WriteLine(); + // return; + // } // Create the output directory Directory.CreateDirectory(outputDirectory);