diff --git a/BinaryObjectScanner/FileType/PKZIP.cs b/BinaryObjectScanner/FileType/PKZIP.cs index 7367c40b..c23e4916 100644 --- a/BinaryObjectScanner/FileType/PKZIP.cs +++ b/BinaryObjectScanner/FileType/PKZIP.cs @@ -44,9 +44,17 @@ namespace BinaryObjectScanner.FileType var readerOptions = new ReaderOptions() { LookForHeader = lookForHeader }; var zipFile = ZipArchive.Open(stream, readerOptions); - // Try to read the file path if no entries are found - if (zipFile.Entries.Count == 0 && !string.IsNullOrEmpty(file) && File.Exists(file)) - zipFile = ZipArchive.Open(file, readerOptions); + // If the file exists + if (!string.IsNullOrEmpty(file) && File.Exists(file!)) + { + // Try to read the file path if no entries are found + if (zipFile.Entries.Count == 0) + zipFile = ZipArchive.Open(file!, readerOptions); + + // If there's any multipart items, try reading the file as well + else if (!zipFile.IsComplete) + zipFile = ZipArchive.Open(file!, readerOptions); + } foreach (var entry in zipFile.Entries) { diff --git a/BinaryObjectScanner/FileType/RAR.cs b/BinaryObjectScanner/FileType/RAR.cs index f5a75ddd..913b286b 100644 --- a/BinaryObjectScanner/FileType/RAR.cs +++ b/BinaryObjectScanner/FileType/RAR.cs @@ -45,9 +45,17 @@ namespace BinaryObjectScanner.FileType var readerOptions = new ReaderOptions() { LookForHeader = lookForHeader }; RarArchive rarFile = RarArchive.Open(stream, readerOptions); - // Try to read the file path if no entries are found - if (rarFile.Entries.Count == 0 && !string.IsNullOrEmpty(file) && File.Exists(file)) - rarFile = RarArchive.Open(file, readerOptions); + // If the file exists + if (!string.IsNullOrEmpty(file) && File.Exists(file!)) + { + // Try to read the file path if no entries are found + if (rarFile.Entries.Count == 0) + rarFile = RarArchive.Open(file!, readerOptions); + + // If there's any multipart items, try reading the file as well + else if (!rarFile.IsComplete) + rarFile = RarArchive.Open(file!, readerOptions); + } if (!rarFile.IsComplete) return false; diff --git a/BinaryObjectScanner/FileType/SevenZip.cs b/BinaryObjectScanner/FileType/SevenZip.cs index 7dbd5931..3a0dfcdd 100644 --- a/BinaryObjectScanner/FileType/SevenZip.cs +++ b/BinaryObjectScanner/FileType/SevenZip.cs @@ -44,9 +44,18 @@ namespace BinaryObjectScanner.FileType { var readerOptions = new ReaderOptions() { LookForHeader = lookForHeader }; var sevenZip = SevenZipArchive.Open(stream, readerOptions); - // Try to read the file path if no entries are found - if (sevenZip.Entries.Count == 0 && !string.IsNullOrEmpty(file) && File.Exists(file)) - sevenZip = SevenZipArchive.Open(file, readerOptions); + + // If the file exists + if (!string.IsNullOrEmpty(file) && File.Exists(file!)) + { + // Try to read the file path if no entries are found + if (sevenZip.Entries.Count == 0) + sevenZip = SevenZipArchive.Open(file!, readerOptions); + + // If there's any multipart items, try reading the file as well + else if (!sevenZip.IsComplete) + sevenZip = SevenZipArchive.Open(file!, readerOptions); + } // Currently doesn't flag solid 7z archives with only 1 solid block as solid, but practically speaking // this is not much of a concern.