diff --git a/docs/API.md b/docs/API.md index 1412c789..6fd2fafa 100644 --- a/docs/API.md +++ b/docs/API.md @@ -85,6 +85,8 @@ using (var archive = ArchiveFactory.OpenArchive(parts)) `InspectArchive` enumerates metadata and returns `ArchiveInformation`. It reports `Partial` status for missing volumes or encrypted headers without a password; malformed archives and incorrect passwords throw. ZIP-specific metadata is exposed through `ArchiveInformation.Zip`. +Detection and inspection result types are in the `SharpCompress.Detection` namespace. + The stream overloads of `DetectArchive` and `InspectArchive` preserve the supplied stream's position and leave it open, including when `ReaderOptions.LeaveStreamOpen` is `false`. #### Migrating from `GetArchiveInformation` diff --git a/docs/FORMATS.md b/docs/FORMATS.md index a9309c06..3a2cde50 100644 --- a/docs/FORMATS.md +++ b/docs/FORMATS.md @@ -31,7 +31,7 @@ 4. The 7Zip format doesn't allow for reading as a forward-only stream, so 7Zip read support is only through the Archive API. Writing is supported through SevenZipWriter for non-solid archives with LZMA/LZMA2 and requires a seekable output stream. See [7Zip Format Notes](#7zip-format-notes) for details on async extraction behavior. 5. LZip has no support for extra data like the file name or timestamp. There is a default filename used when looking at the entry Key on the archive. -`ArchiveFactory.DetectArchive(...)` reports which APIs in this table are available through `ArchiveDetection.SupportedApis`. Reader-only formats include Ace, Arc, Arj, and standalone LZW. Compressed TAR wrappers are detected as a TAR container with an outer compression type and support the Reader API, not the Archive API. Use `ArchiveFactory.InspectArchive(...)` when complete archive metadata is required. +`ArchiveFactory.DetectArchive(...)` reports which APIs in this table are available through `SharpCompress.Detection.ArchiveDetection.SupportedApis`. Reader-only formats include Ace, Arc, Arj, and standalone LZW. Compressed TAR wrappers are detected as a TAR container with an outer compression type and support the Reader API, not the Archive API. Use `ArchiveFactory.InspectArchive(...)` when complete archive metadata is required. ### Zip Format Notes diff --git a/docs/USAGE.md b/docs/USAGE.md index 838cd16f..91e6331a 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -230,6 +230,8 @@ using (var archive = ArchiveFactory.OpenArchive("archive.zip")) ### Detect the format and choose the right API ```C# +using SharpCompress.Detection; + var archivePath = "archive.arc"; var detection = ArchiveFactory.DetectArchive(archivePath); if (detection is null) @@ -264,6 +266,8 @@ if (information is not null) `InspectArchive` parses archive metadata, which can require a complete sequential scan for TAR and compressed TAR files. It returns partial information for encrypted headers without a password or missing archive parts; inspect `Status` and `Limitations` before using nullable metadata values. +Detection and inspection result types are in the `SharpCompress.Detection` namespace. + The stream overload preserves the caller's current position and leaves the supplied stream open. ### Open multi-volume archives diff --git a/src/SharpCompress/Archives/ArchiveFactory.Detection.cs b/src/SharpCompress/Archives/ArchiveFactory.Detection.cs index caedc7fd..88168d92 100644 --- a/src/SharpCompress/Archives/ArchiveFactory.Detection.cs +++ b/src/SharpCompress/Archives/ArchiveFactory.Detection.cs @@ -4,6 +4,7 @@ using System.Threading; using System.Threading.Tasks; using SharpCompress.Archives.Tar; using SharpCompress.Common; +using SharpCompress.Detection; using SharpCompress.Factories; using SharpCompress.IO; using SharpCompress.Providers; diff --git a/src/SharpCompress/Archives/ArchiveFactory.Information.Async.cs b/src/SharpCompress/Archives/ArchiveFactory.Information.Async.cs index cb5b763a..1f26bd3e 100644 --- a/src/SharpCompress/Archives/ArchiveFactory.Information.Async.cs +++ b/src/SharpCompress/Archives/ArchiveFactory.Information.Async.cs @@ -11,6 +11,7 @@ using SharpCompress.Common; using SharpCompress.Common.Ace.Headers; using SharpCompress.Common.Rar; using SharpCompress.Common.Zip; +using SharpCompress.Detection; using SharpCompress.IO; using SharpCompress.Readers; diff --git a/src/SharpCompress/Archives/ArchiveFactory.Information.cs b/src/SharpCompress/Archives/ArchiveFactory.Information.cs index 01a06ed5..b89774ef 100644 --- a/src/SharpCompress/Archives/ArchiveFactory.Information.cs +++ b/src/SharpCompress/Archives/ArchiveFactory.Information.cs @@ -11,6 +11,7 @@ using SharpCompress.Common; using SharpCompress.Common.Rar; using SharpCompress.Common.Zip; using SharpCompress.Common.Zip.Headers; +using SharpCompress.Detection; using SharpCompress.IO; using SharpCompress.Readers; using AceMainHeader = SharpCompress.Common.Ace.Headers.AceMainHeader; diff --git a/src/SharpCompress/Archives/ArchiveAccessMode.cs b/src/SharpCompress/Detection/ArchiveAccessMode.cs similarity index 93% rename from src/SharpCompress/Archives/ArchiveAccessMode.cs rename to src/SharpCompress/Detection/ArchiveAccessMode.cs index a86afdb2..8826f2d8 100644 --- a/src/SharpCompress/Archives/ArchiveAccessMode.cs +++ b/src/SharpCompress/Detection/ArchiveAccessMode.cs @@ -1,6 +1,6 @@ using System; -namespace SharpCompress.Archives; +namespace SharpCompress.Detection; /// /// Specifies the APIs available for an archive format. diff --git a/src/SharpCompress/Archives/ArchiveDetection.cs b/src/SharpCompress/Detection/ArchiveDetection.cs similarity index 97% rename from src/SharpCompress/Archives/ArchiveDetection.cs rename to src/SharpCompress/Detection/ArchiveDetection.cs index fe961af8..c01cf4b5 100644 --- a/src/SharpCompress/Archives/ArchiveDetection.cs +++ b/src/SharpCompress/Detection/ArchiveDetection.cs @@ -1,6 +1,6 @@ using SharpCompress.Common; -namespace SharpCompress.Archives; +namespace SharpCompress.Detection; /// /// Identifies an archive format without enumerating its entries. diff --git a/src/SharpCompress/Archives/ArchiveEncryptionScope.cs b/src/SharpCompress/Detection/ArchiveEncryptionScope.cs similarity index 92% rename from src/SharpCompress/Archives/ArchiveEncryptionScope.cs rename to src/SharpCompress/Detection/ArchiveEncryptionScope.cs index 5299e9bf..2e3afe8c 100644 --- a/src/SharpCompress/Archives/ArchiveEncryptionScope.cs +++ b/src/SharpCompress/Detection/ArchiveEncryptionScope.cs @@ -1,6 +1,6 @@ using System; -namespace SharpCompress.Archives; +namespace SharpCompress.Detection; /// /// Identifies which archive data is encrypted. diff --git a/src/SharpCompress/Archives/ArchiveInformation.cs b/src/SharpCompress/Detection/ArchiveInformation.cs similarity index 99% rename from src/SharpCompress/Archives/ArchiveInformation.cs rename to src/SharpCompress/Detection/ArchiveInformation.cs index 68468771..fac49816 100644 --- a/src/SharpCompress/Archives/ArchiveInformation.cs +++ b/src/SharpCompress/Detection/ArchiveInformation.cs @@ -1,4 +1,4 @@ -namespace SharpCompress.Archives; +namespace SharpCompress.Detection; /// /// Contains metadata collected by fully inspecting an archive. diff --git a/src/SharpCompress/Archives/ArchiveInformationLimitations.cs b/src/SharpCompress/Detection/ArchiveInformationLimitations.cs similarity index 94% rename from src/SharpCompress/Archives/ArchiveInformationLimitations.cs rename to src/SharpCompress/Detection/ArchiveInformationLimitations.cs index 26f2cd3a..592f6ed6 100644 --- a/src/SharpCompress/Archives/ArchiveInformationLimitations.cs +++ b/src/SharpCompress/Detection/ArchiveInformationLimitations.cs @@ -1,6 +1,6 @@ using System; -namespace SharpCompress.Archives; +namespace SharpCompress.Detection; /// /// Identifies conditions that prevented complete archive metadata inspection. diff --git a/src/SharpCompress/Archives/ArchiveInformationStatus.cs b/src/SharpCompress/Detection/ArchiveInformationStatus.cs similarity index 91% rename from src/SharpCompress/Archives/ArchiveInformationStatus.cs rename to src/SharpCompress/Detection/ArchiveInformationStatus.cs index dabee58b..5d37f534 100644 --- a/src/SharpCompress/Archives/ArchiveInformationStatus.cs +++ b/src/SharpCompress/Detection/ArchiveInformationStatus.cs @@ -1,4 +1,4 @@ -namespace SharpCompress.Archives; +namespace SharpCompress.Detection; /// /// Describes whether archive metadata could be collected completely. diff --git a/src/SharpCompress/Archives/ZipArchiveInformation.cs b/src/SharpCompress/Detection/ZipArchiveInformation.cs similarity index 93% rename from src/SharpCompress/Archives/ZipArchiveInformation.cs rename to src/SharpCompress/Detection/ZipArchiveInformation.cs index 80bc76cd..63e46e1b 100644 --- a/src/SharpCompress/Archives/ZipArchiveInformation.cs +++ b/src/SharpCompress/Detection/ZipArchiveInformation.cs @@ -1,4 +1,4 @@ -namespace SharpCompress.Archives; +namespace SharpCompress.Detection; /// /// Contains ZIP-specific metadata. diff --git a/tests/SharpCompress.Test/ArchiveFactoryTests.cs b/tests/SharpCompress.Test/ArchiveFactoryTests.cs index 2de784f9..85fbca99 100644 --- a/tests/SharpCompress.Test/ArchiveFactoryTests.cs +++ b/tests/SharpCompress.Test/ArchiveFactoryTests.cs @@ -4,6 +4,7 @@ using System.Text; using System.Threading.Tasks; using SharpCompress.Archives; using SharpCompress.Common; +using SharpCompress.Detection; using SharpCompress.Factories; using SharpCompress.Readers; using SharpCompress.Test.Mocks;