From 2e77082c819a2662093682c7f45b754c2a22b203 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Sat, 21 Feb 2026 17:45:09 +0000 Subject: [PATCH] added home dir and unknown entry --- src/SharpCompress.Cli/Inspection/ArchiveInspector.cs | 7 ++++++- src/SharpCompress/Common/SevenZip/SevenZipFilePart.cs | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/SharpCompress.Cli/Inspection/ArchiveInspector.cs b/src/SharpCompress.Cli/Inspection/ArchiveInspector.cs index 063cfebf..b5442f84 100644 --- a/src/SharpCompress.Cli/Inspection/ArchiveInspector.cs +++ b/src/SharpCompress.Cli/Inspection/ArchiveInspector.cs @@ -42,7 +42,12 @@ public sealed class ArchiveInspector throw new ArgumentException("Archive path is required.", nameof(archivePath)); } - var fileInfo = new FileInfo(archivePath); + // Handle tilde expansion for home directory, then convert relative paths to absolute paths + var expandedPath = archivePath.StartsWith('~') + ? archivePath.Replace("~", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), StringComparison.Ordinal) + : archivePath; + var fullPath = Path.GetFullPath(expandedPath); + var fileInfo = new FileInfo(fullPath); if (!fileInfo.Exists) { throw new FileNotFoundException($"Archive file was not found: {fileInfo.FullName}"); diff --git a/src/SharpCompress/Common/SevenZip/SevenZipFilePart.cs b/src/SharpCompress/Common/SevenZip/SevenZipFilePart.cs index 65bb7503..d9d7da0e 100644 --- a/src/SharpCompress/Common/SevenZip/SevenZipFilePart.cs +++ b/src/SharpCompress/Common/SevenZip/SevenZipFilePart.cs @@ -108,7 +108,11 @@ internal class SevenZipFilePart : FilePart return CompressionType.None; } - var coder = Folder.NotNull()._coders.First(); + var coder = Folder?._coders.FirstOrDefault(); + if (coder == null) + { + return CompressionType.Unknown; + } return coder._methodId._id switch { K_COPY => CompressionType.None,