diff --git a/src/SharpCompress/Common/ExtractionMethods.cs b/src/SharpCompress/Common/ExtractionMethods.cs index 0e3889bf..485fdf4d 100644 --- a/src/SharpCompress/Common/ExtractionMethods.cs +++ b/src/SharpCompress/Common/ExtractionMethods.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; @@ -12,7 +13,7 @@ internal static class ExtractionMethods /// Windows uses case-insensitive file systems, while Unix-like systems use case-sensitive file systems. /// private static StringComparison PathComparison => - Environment.OSVersion.Platform == PlatformID.Win32NT + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; diff --git a/tests/SharpCompress.Test/ExtractionTests.cs b/tests/SharpCompress.Test/ExtractionTests.cs index baf12d30..04b5b08f 100644 --- a/tests/SharpCompress.Test/ExtractionTests.cs +++ b/tests/SharpCompress.Test/ExtractionTests.cs @@ -13,11 +13,12 @@ public class ExtractionTests : TestBase [Fact] public void Extraction_ShouldHandleCaseInsensitivePathsOnWindows() { - // This test simulates the issue where Path.GetFullPath returns paths with different casing - // than the actual directory on disk (e.g., "system32" vs "System32" on Windows). - // On Windows, file paths are case-insensitive, so the extraction should succeed. - // On Unix-like systems, file paths are case-sensitive, so this test validates the - // platform-specific behavior. + // This test validates that extraction succeeds when Path.GetFullPath returns paths + // with casing that matches the platform's file system behavior. On Windows, + // Path.GetFullPath can return different casing than the actual directory on disk + // (e.g., "system32" vs "System32"), and the extraction should succeed because + // Windows file systems are case-insensitive. On Unix-like systems, this test + // verifies that the case-sensitive comparison is used correctly. var testArchive = Path.Combine(SCRATCH2_FILES_PATH, "test-extraction.zip"); var extractPath = SCRATCH_FILES_PATH;