mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-22 06:54:40 +00:00
use sync generator
This commit is contained in:
@@ -528,6 +528,7 @@ public static partial class ArchiveFactory
|
||||
_ => entries.Aggregate(0L, (total, entry) => total + entry.CompressedSize),
|
||||
};
|
||||
|
||||
[Zomp.SyncMethodGenerator.CreateSyncVersion]
|
||||
private static async ValueTask<(
|
||||
ZipArchiveInformation? Information,
|
||||
long DeferredSizeEntryCount
|
||||
@@ -545,7 +546,9 @@ public static partial class ArchiveFactory
|
||||
long deferredSizeEntryCount = 0;
|
||||
foreach (var entry in entries.OfType<ZipArchiveEntry>())
|
||||
{
|
||||
#if !SYNC_ONLY
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
#endif
|
||||
var filePart = entry.Parts.OfType<SeekableZipFilePart>().Single();
|
||||
if (!filePart.HasDeferredSizes)
|
||||
{
|
||||
|
||||
@@ -387,35 +387,6 @@ public static partial class ArchiveFactory
|
||||
? ArchiveInformationStatus.Complete
|
||||
: ArchiveInformationStatus.Partial;
|
||||
|
||||
private static (
|
||||
ZipArchiveInformation? Information,
|
||||
long DeferredSizeEntryCount
|
||||
) GetZipInformation(bool isZipArchive, IEnumerable<IArchiveEntry> entries)
|
||||
{
|
||||
if (!isZipArchive)
|
||||
{
|
||||
return (null, 0);
|
||||
}
|
||||
|
||||
long deferredSizeEntryCount = 0;
|
||||
foreach (var entry in entries.OfType<ZipArchiveEntry>())
|
||||
{
|
||||
var filePart = entry.Parts.OfType<SeekableZipFilePart>().Single();
|
||||
if (!filePart.HasDeferredSizes)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var localHeader = filePart.GetRawLocalHeader();
|
||||
if (localHeader.CompressedSize == 0 && localHeader.UncompressedSize == 0)
|
||||
{
|
||||
deferredSizeEntryCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return (new ZipArchiveInformation(deferredSizeEntryCount > 0), deferredSizeEntryCount);
|
||||
}
|
||||
|
||||
private static (bool IsSolid, long SolidStreamCount) GetSolidInformation(
|
||||
IArchive archive,
|
||||
IReadOnlyCollection<IArchiveEntry> entries
|
||||
|
||||
@@ -26,6 +26,9 @@ internal partial class SeekableZipFilePart
|
||||
.GetLocalHeaderAsync(BaseStream, _directoryEntryHeader)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
internal ValueTask<LocalEntryHeader> GetRawLocalHeaderAsync() =>
|
||||
_headerFactory.GetRawLocalHeaderAsync(BaseStream, _directoryEntryHeader);
|
||||
[Zomp.SyncMethodGenerator.CreateSyncVersion]
|
||||
internal async ValueTask<LocalEntryHeader> GetRawLocalHeaderAsync() =>
|
||||
await _headerFactory
|
||||
.GetRawLocalHeaderAsync(BaseStream, _directoryEntryHeader)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@ internal partial class SeekableZipFilePart : ZipFilePart
|
||||
_directoryEntryHeader = header;
|
||||
}
|
||||
|
||||
internal LocalEntryHeader GetRawLocalHeader() =>
|
||||
_headerFactory.GetRawLocalHeader(BaseStream, _directoryEntryHeader);
|
||||
|
||||
internal bool HasDeferredSizes =>
|
||||
FlagUtility.HasFlag(_directoryEntryHeader.Flags, HeaderFlags.UsePostDataDescriptor);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user