From 1b4cedfa13188fcd7896b1a03fc1902d3907cfb3 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 12 Jan 2026 16:21:20 +0000 Subject: [PATCH] misc fixes --- SharpCompress.sln | 2 -- src/SharpCompress/Archives/AbstractArchive.cs | 6 ++++-- src/SharpCompress/Archives/IArchive.cs | 5 ++++- src/SharpCompress/Archives/IArchiveExtensions.cs | 2 +- src/SharpCompress/Archives/IAsyncArchive.cs | 7 ++++++- src/SharpCompress/Archives/IAsyncArchiveExtensions.cs | 2 +- src/SharpCompress/Archives/IWritableArchive.cs | 10 ++++++++++ 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/SharpCompress.sln b/SharpCompress.sln index ba04063b..353e73d7 100644 --- a/SharpCompress.sln +++ b/SharpCompress.sln @@ -21,9 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{CDB425 Directory.Packages.props = Directory.Packages.props NuGet.config = NuGet.config .github\workflows\nuget-release.yml = .github\workflows\nuget-release.yml - USAGE.md = USAGE.md README.md = README.md - FORMATS.md = FORMATS.md AGENTS.md = AGENTS.md EndProjectSection EndProject diff --git a/src/SharpCompress/Archives/AbstractArchive.cs b/src/SharpCompress/Archives/AbstractArchive.cs index 844035cd..63e67e69 100644 --- a/src/SharpCompress/Archives/AbstractArchive.cs +++ b/src/SharpCompress/Archives/AbstractArchive.cs @@ -68,7 +68,7 @@ public abstract class AbstractArchive : IArchive, IAsyncArchive /// /// The total size of the files as uncompressed in the archive. /// - public virtual long TotalUncompressSize => + public virtual long TotalUncompressedSize => Entries.Aggregate(0L, (total, cf) => total + cf.Size); protected abstract IEnumerable LoadVolumes(SourceStream sourceStream); @@ -231,8 +231,10 @@ public abstract class AbstractArchive : IArchive, IAsyncArchive public async ValueTask TotalSizeAsync() => await EntriesAsync.AggregateAsync(0L, (total, cf) => total + cf.CompressedSize); - public async ValueTask TotalUncompressSizeAsync() => + public async ValueTask TotalUncompressedSizeAsync() => await EntriesAsync.AggregateAsync(0L, (total, cf) => total + cf.Size); + public ValueTask IsEncryptedAsync() => new(IsEncrypted); + #endregion } diff --git a/src/SharpCompress/Archives/IArchive.cs b/src/SharpCompress/Archives/IArchive.cs index 0abb2f1b..6016214b 100644 --- a/src/SharpCompress/Archives/IArchive.cs +++ b/src/SharpCompress/Archives/IArchive.cs @@ -38,7 +38,10 @@ public interface IArchive : IDisposable /// /// The total size of the files as uncompressed in the archive. /// - long TotalUncompressSize { get; } + long TotalUncompressedSize { get; } + /// + /// Returns whether the archive is encrypted. + /// bool IsEncrypted { get; } } diff --git a/src/SharpCompress/Archives/IArchiveExtensions.cs b/src/SharpCompress/Archives/IArchiveExtensions.cs index c1d2ac98..f02dfc38 100644 --- a/src/SharpCompress/Archives/IArchiveExtensions.cs +++ b/src/SharpCompress/Archives/IArchiveExtensions.cs @@ -43,7 +43,7 @@ public static class IArchiveExtensions ) { // Prepare for progress reporting - var totalBytes = archive.TotalUncompressSize; + var totalBytes = archive.TotalUncompressedSize; var bytesRead = 0L; // Tracking for created directories. diff --git a/src/SharpCompress/Archives/IAsyncArchive.cs b/src/SharpCompress/Archives/IAsyncArchive.cs index bd3f290e..2994e8b8 100644 --- a/src/SharpCompress/Archives/IAsyncArchive.cs +++ b/src/SharpCompress/Archives/IAsyncArchive.cs @@ -39,5 +39,10 @@ public interface IAsyncArchive : IAsyncDisposable /// /// The total size of the files as uncompressed in the archive. /// - ValueTask TotalUncompressSizeAsync(); + ValueTask TotalUncompressedSizeAsync(); + + /// + /// Returns whether the archive is encrypted. + /// + ValueTask IsEncryptedAsync(); } diff --git a/src/SharpCompress/Archives/IAsyncArchiveExtensions.cs b/src/SharpCompress/Archives/IAsyncArchiveExtensions.cs index b6b0cad1..128258b3 100644 --- a/src/SharpCompress/Archives/IAsyncArchiveExtensions.cs +++ b/src/SharpCompress/Archives/IAsyncArchiveExtensions.cs @@ -53,7 +53,7 @@ public static class IAsyncArchiveExtensions ) { // Prepare for progress reporting - var totalBytes = await archive.TotalUncompressSizeAsync(); + var totalBytes = await archive.TotalUncompressedSizeAsync(); var bytesRead = 0L; // Tracking for created directories. diff --git a/src/SharpCompress/Archives/IWritableArchive.cs b/src/SharpCompress/Archives/IWritableArchive.cs index 7c10910c..28496b48 100644 --- a/src/SharpCompress/Archives/IWritableArchive.cs +++ b/src/SharpCompress/Archives/IWritableArchive.cs @@ -13,6 +13,10 @@ public interface IWritableArchiveCommon /// /// IDisposeable to resume entry rebuilding IDisposable PauseEntryRebuilding(); + + /// + /// Removes the specified entry from the archive. + /// void RemoveEntry(IArchiveEntry entry); IArchiveEntry AddEntry( @@ -28,11 +32,17 @@ public interface IWritableArchiveCommon public interface IWritableArchive : IArchive, IWritableArchiveCommon { + /// + /// Saves the archive to the specified stream using the given writer options. + /// void SaveTo(Stream stream, WriterOptions options); } public interface IWritableAsyncArchive : IAsyncArchive, IWritableArchiveCommon { + /// + /// Asynchronously saves the archive to the specified stream using the given writer options. + /// ValueTask SaveToAsync( Stream stream, WriterOptions options,