Downstream changes from Serialization for now

This commit is contained in:
Matt Nadareski
2025-08-25 13:24:22 -04:00
parent 9b49f7c597
commit 43649851ca
3 changed files with 34 additions and 9 deletions

View File

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

View File

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

View File

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