From 2f1007bb3babddd2917d021608bc3a6b3202b604 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 18 Feb 2026 09:00:47 +0000 Subject: [PATCH] moar interfaces --- src/SharpCompress/Archives/GZip/GZipArchive.cs | 4 ++-- src/SharpCompress/Archives/GZip/IGZipArchive.cs | 13 +++++++++++++ src/SharpCompress/Archives/Tar/ITarArchive.cs | 13 +++++++++++++ src/SharpCompress/Archives/Tar/TarArchive.cs | 4 ++-- src/SharpCompress/Archives/Zip/IZipArchive.cs | 13 +++++++++++++ src/SharpCompress/Archives/Zip/ZipArchive.cs | 4 ++-- src/SharpCompress/Factories/GZipFactory.cs | 6 +++++- src/SharpCompress/Factories/TarFactory.cs | 5 ++++- src/SharpCompress/Factories/ZipFactory.cs | 5 ++++- 9 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/SharpCompress/Archives/GZip/GZipArchive.cs b/src/SharpCompress/Archives/GZip/GZipArchive.cs index 4f2d1f4b..63008e1d 100644 --- a/src/SharpCompress/Archives/GZip/GZipArchive.cs +++ b/src/SharpCompress/Archives/GZip/GZipArchive.cs @@ -15,8 +15,8 @@ namespace SharpCompress.Archives.GZip; public partial class GZipArchive : AbstractWritableArchive, - IGZipArchive, - IGZipAsyncArchive + IGZipWritableArchive, + IGZipWritableAsyncArchive { private GZipArchive(SourceStream sourceStream) : base(ArchiveType.GZip, sourceStream) { } diff --git a/src/SharpCompress/Archives/GZip/IGZipArchive.cs b/src/SharpCompress/Archives/GZip/IGZipArchive.cs index da0a8f60..1ca411e3 100644 --- a/src/SharpCompress/Archives/GZip/IGZipArchive.cs +++ b/src/SharpCompress/Archives/GZip/IGZipArchive.cs @@ -1,4 +1,5 @@ using SharpCompress.Common; +using SharpCompress.Writers.GZip; namespace SharpCompress.Archives.GZip; @@ -7,7 +8,19 @@ namespace SharpCompress.Archives.GZip; /// public interface IGZipArchive : IExtractableArchive { } +/// +/// Writable GZip archive with GZip-specific writer options. +/// +public interface IGZipWritableArchive : IGZipArchive, IWritableArchive { } + /// /// Async GZip archive supporting random access and entry stream extraction. /// public interface IGZipAsyncArchive : IExtractableAsyncArchive { } + +/// +/// Async writable GZip archive with GZip-specific writer options. +/// +public interface IGZipWritableAsyncArchive + : IGZipAsyncArchive, + IWritableAsyncArchive { } diff --git a/src/SharpCompress/Archives/Tar/ITarArchive.cs b/src/SharpCompress/Archives/Tar/ITarArchive.cs index ea66f3bf..c7969769 100644 --- a/src/SharpCompress/Archives/Tar/ITarArchive.cs +++ b/src/SharpCompress/Archives/Tar/ITarArchive.cs @@ -1,4 +1,5 @@ using SharpCompress.Common; +using SharpCompress.Writers.Tar; namespace SharpCompress.Archives.Tar; @@ -7,7 +8,19 @@ namespace SharpCompress.Archives.Tar; /// public interface ITarArchive : IExtractableArchive { } +/// +/// Writable TAR archive with TAR-specific writer options. +/// +public interface ITarWritableArchive : ITarArchive, IWritableArchive { } + /// /// Async TAR archive supporting random access and entry stream extraction. /// public interface ITarAsyncArchive : IExtractableAsyncArchive { } + +/// +/// Async writable TAR archive with TAR-specific writer options. +/// +public interface ITarWritableAsyncArchive + : ITarAsyncArchive, + IWritableAsyncArchive { } diff --git a/src/SharpCompress/Archives/Tar/TarArchive.cs b/src/SharpCompress/Archives/Tar/TarArchive.cs index 455d3e11..da8e7488 100644 --- a/src/SharpCompress/Archives/Tar/TarArchive.cs +++ b/src/SharpCompress/Archives/Tar/TarArchive.cs @@ -18,8 +18,8 @@ namespace SharpCompress.Archives.Tar; public partial class TarArchive : AbstractWritableArchive, - ITarArchive, - ITarAsyncArchive + ITarWritableArchive, + ITarWritableAsyncArchive { private readonly CompressionType _compressionType; diff --git a/src/SharpCompress/Archives/Zip/IZipArchive.cs b/src/SharpCompress/Archives/Zip/IZipArchive.cs index 811b5d4a..b3f7724a 100644 --- a/src/SharpCompress/Archives/Zip/IZipArchive.cs +++ b/src/SharpCompress/Archives/Zip/IZipArchive.cs @@ -1,4 +1,5 @@ using SharpCompress.Common; +using SharpCompress.Writers.Zip; namespace SharpCompress.Archives.Zip; @@ -7,7 +8,19 @@ namespace SharpCompress.Archives.Zip; /// public interface IZipArchive : IExtractableArchive { } +/// +/// Writable ZIP archive with ZIP-specific writer options. +/// +public interface IZipWritableArchive : IZipArchive, IWritableArchive { } + /// /// Async ZIP archive supporting random access and entry stream extraction. /// public interface IZipAsyncArchive : IExtractableAsyncArchive { } + +/// +/// Async writable ZIP archive with ZIP-specific writer options. +/// +public interface IZipWritableAsyncArchive + : IZipAsyncArchive, + IWritableAsyncArchive { } diff --git a/src/SharpCompress/Archives/Zip/ZipArchive.cs b/src/SharpCompress/Archives/Zip/ZipArchive.cs index 655f1f2b..49ea7476 100644 --- a/src/SharpCompress/Archives/Zip/ZipArchive.cs +++ b/src/SharpCompress/Archives/Zip/ZipArchive.cs @@ -19,8 +19,8 @@ namespace SharpCompress.Archives.Zip; public partial class ZipArchive : AbstractWritableArchive, - IZipArchive, - IZipAsyncArchive + IZipWritableArchive, + IZipWritableAsyncArchive { private readonly SeekableZipHeaderFactory? headerFactory; diff --git a/src/SharpCompress/Factories/GZipFactory.cs b/src/SharpCompress/Factories/GZipFactory.cs index e4062e62..cb431ea2 100644 --- a/src/SharpCompress/Factories/GZipFactory.cs +++ b/src/SharpCompress/Factories/GZipFactory.cs @@ -206,7 +206,11 @@ public class GZipFactory #region IWriteableArchiveFactory /// - public IWritableArchive CreateArchive() => GZipArchive.CreateArchive(); + public IGZipWritableArchive CreateArchive() => + (IGZipWritableArchive)GZipArchive.CreateArchive(); + + IWritableArchive IWriteableArchiveFactory.CreateArchive() => + CreateArchive(); #endregion } diff --git a/src/SharpCompress/Factories/TarFactory.cs b/src/SharpCompress/Factories/TarFactory.cs index 32014744..3555b57c 100644 --- a/src/SharpCompress/Factories/TarFactory.cs +++ b/src/SharpCompress/Factories/TarFactory.cs @@ -409,7 +409,10 @@ public class TarFactory #region IWriteableArchiveFactory /// - public IWritableArchive CreateArchive() => TarArchive.CreateArchive(); + public ITarWritableArchive CreateArchive() => (ITarWritableArchive)TarArchive.CreateArchive(); + + IWritableArchive IWriteableArchiveFactory.CreateArchive() => + CreateArchive(); #endregion } diff --git a/src/SharpCompress/Factories/ZipFactory.cs b/src/SharpCompress/Factories/ZipFactory.cs index d93d14b5..b1b6dd4e 100644 --- a/src/SharpCompress/Factories/ZipFactory.cs +++ b/src/SharpCompress/Factories/ZipFactory.cs @@ -234,7 +234,10 @@ public class ZipFactory #region IWriteableArchiveFactory /// - public IWritableArchive CreateArchive() => ZipArchive.CreateArchive(); + public IZipWritableArchive CreateArchive() => (IZipWritableArchive)ZipArchive.CreateArchive(); + + IWritableArchive IWriteableArchiveFactory.CreateArchive() => + CreateArchive(); #endregion }