From ebd784cfb2c00192291d652aeadb1f438b565265 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 6 Mar 2026 15:16:28 +0000 Subject: [PATCH] code review changes --- src/SharpCompress/Archives/ArchiveFactory.Async.cs | 3 +-- src/SharpCompress/Archives/IWritableArchiveExtensions.cs | 8 +++----- .../Archives/IWritableAsyncArchiveExtensions.cs | 8 +++----- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/SharpCompress/Archives/ArchiveFactory.Async.cs b/src/SharpCompress/Archives/ArchiveFactory.Async.cs index 0ae6c910..67d71b70 100644 --- a/src/SharpCompress/Archives/ArchiveFactory.Async.cs +++ b/src/SharpCompress/Archives/ArchiveFactory.Async.cs @@ -6,7 +6,6 @@ using System.Threading; using System.Threading.Tasks; using SharpCompress.Common; using SharpCompress.Factories; -using SharpCompress.IO; using SharpCompress.Readers; namespace SharpCompress.Archives; @@ -123,7 +122,7 @@ public static partial class ArchiveFactory return FindFactoryAsync(new FileInfo(filePath), cancellationToken); } - public static async ValueTask FindFactoryAsync( + private static async ValueTask FindFactoryAsync( FileInfo finfo, CancellationToken cancellationToken = default ) diff --git a/src/SharpCompress/Archives/IWritableArchiveExtensions.cs b/src/SharpCompress/Archives/IWritableArchiveExtensions.cs index f6ce3ff2..f349f06d 100644 --- a/src/SharpCompress/Archives/IWritableArchiveExtensions.cs +++ b/src/SharpCompress/Archives/IWritableArchiveExtensions.cs @@ -1,8 +1,6 @@ using System; using System.IO; -using SharpCompress.Common; using SharpCompress.Common.Options; -using SharpCompress.Writers; namespace SharpCompress.Archives; @@ -11,7 +9,7 @@ public static class IWritableArchiveExtensions extension(IWritableArchive writableArchive) { public void AddAllFromDirectory( - string filePath, + string directoryPath, string searchPattern = "*.*", SearchOption searchOption = SearchOption.AllDirectories ) @@ -19,12 +17,12 @@ public static class IWritableArchiveExtensions using (writableArchive.PauseEntryRebuilding()) { foreach ( - var path in Directory.EnumerateFiles(filePath, searchPattern, searchOption) + var filePath in Directory.EnumerateFiles(directoryPath, searchPattern, searchOption) ) { var fileInfo = new FileInfo(filePath); writableArchive.AddEntry( - path.Substring(filePath.Length), + Path.GetFileName(filePath), fileInfo.OpenRead(), true, fileInfo.Length, diff --git a/src/SharpCompress/Archives/IWritableAsyncArchiveExtensions.cs b/src/SharpCompress/Archives/IWritableAsyncArchiveExtensions.cs index 6e848b21..72110966 100644 --- a/src/SharpCompress/Archives/IWritableAsyncArchiveExtensions.cs +++ b/src/SharpCompress/Archives/IWritableAsyncArchiveExtensions.cs @@ -2,9 +2,7 @@ using System; using System.IO; using System.Threading; using System.Threading.Tasks; -using SharpCompress.Common; using SharpCompress.Common.Options; -using SharpCompress.Writers; namespace SharpCompress.Archives; @@ -13,7 +11,7 @@ public static class IWritableAsyncArchiveExtensions extension(IWritableAsyncArchive writableArchive) { public async ValueTask AddAllFromDirectoryAsync( - string filePath, + string directoryPath, string searchPattern = "*.*", SearchOption searchOption = SearchOption.AllDirectories ) @@ -21,13 +19,13 @@ public static class IWritableAsyncArchiveExtensions using (writableArchive.PauseEntryRebuilding()) { foreach ( - var path in Directory.EnumerateFiles(filePath, searchPattern, searchOption) + var filePath in Directory.EnumerateFiles(directoryPath, searchPattern, searchOption) ) { var fileInfo = new FileInfo(filePath); await writableArchive .AddEntryAsync( - path.Substring(filePath.Length), + Path.GetFileName(filePath), fileInfo.OpenRead(), true, fileInfo.Length,