mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-23 07:14:57 +00:00
Maybe fix multipart 7z, RAR, and PKZIP archives
This commit is contained in:
@@ -100,9 +100,17 @@ namespace SabreTools.Serialization.Wrappers
|
||||
var readerOptions = new ReaderOptions() { LookForHeader = lookForHeader };
|
||||
var zipFile = ZipArchive.Open(_dataSource, readerOptions);
|
||||
|
||||
// Try to read the file path if no entries are found
|
||||
if (zipFile.Entries.Count == 0 && !string.IsNullOrEmpty(Filename) && File.Exists(Filename!))
|
||||
zipFile = ZipArchive.Open(Filename!, readerOptions);
|
||||
// If the file exists
|
||||
if (!string.IsNullOrEmpty(Filename) && File.Exists(Filename!))
|
||||
{
|
||||
// Try to read the file path if no entries are found
|
||||
if (zipFile.Entries.Count == 0)
|
||||
zipFile = ZipArchive.Open(Filename!, readerOptions);
|
||||
|
||||
// If there's any multipart items, try reading the file as well
|
||||
else if (System.Array.Exists([.. zipFile.Entries], e => !e.IsComplete))
|
||||
zipFile = ZipArchive.Open(Filename!, readerOptions);
|
||||
}
|
||||
|
||||
foreach (var entry in zipFile.Entries)
|
||||
{
|
||||
|
||||
@@ -103,9 +103,17 @@ namespace SabreTools.Serialization.Wrappers
|
||||
var readerOptions = new ReaderOptions() { LookForHeader = lookForHeader };
|
||||
RarArchive rarFile = RarArchive.Open(_dataSource, readerOptions);
|
||||
|
||||
// Try to read the file path if no entries are found
|
||||
if (rarFile.Entries.Count == 0 && !string.IsNullOrEmpty(Filename) && File.Exists(Filename!))
|
||||
rarFile = RarArchive.Open(Filename!, readerOptions);
|
||||
// If the file exists
|
||||
if (!string.IsNullOrEmpty(Filename) && File.Exists(Filename!))
|
||||
{
|
||||
// Try to read the file path if no entries are found
|
||||
if (rarFile.Entries.Count == 0)
|
||||
rarFile = RarArchive.Open(Filename!, readerOptions);
|
||||
|
||||
// If there's any multipart items, try reading the file as well
|
||||
else if (System.Array.Exists([.. rarFile.Entries], e => !e.IsComplete))
|
||||
rarFile = RarArchive.Open(Filename!, readerOptions);
|
||||
}
|
||||
|
||||
if (!rarFile.IsComplete)
|
||||
return false;
|
||||
|
||||
@@ -102,9 +102,18 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
var readerOptions = new ReaderOptions() { LookForHeader = lookForHeader };
|
||||
var sevenZip = SevenZipArchive.Open(_dataSource, readerOptions);
|
||||
// Try to read the file path if no entries are found
|
||||
if (sevenZip.Entries.Count == 0 && !string.IsNullOrEmpty(Filename) && File.Exists(Filename!))
|
||||
sevenZip = SevenZipArchive.Open(Filename!, readerOptions);
|
||||
|
||||
// If the file exists
|
||||
if (!string.IsNullOrEmpty(Filename) && File.Exists(Filename!))
|
||||
{
|
||||
// Try to read the file path if no entries are found
|
||||
if (sevenZip.Entries.Count == 0)
|
||||
sevenZip = SevenZipArchive.Open(Filename!, readerOptions);
|
||||
|
||||
// If there's any multipart items, try reading the file as well
|
||||
else if (System.Array.Exists([.. sevenZip.Entries], e => !e.IsComplete))
|
||||
sevenZip = SevenZipArchive.Open(Filename!, 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.
|
||||
|
||||
Reference in New Issue
Block a user