From c7d9177e68c1367d498fc146eff382769c7bac3c Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 27 Apr 2024 22:04:38 -0400 Subject: [PATCH] Allow decompression to be skipped --- SabreTools.Serialization/PathProcessor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SabreTools.Serialization/PathProcessor.cs b/SabreTools.Serialization/PathProcessor.cs index a728767f..de51a4af 100644 --- a/SabreTools.Serialization/PathProcessor.cs +++ b/SabreTools.Serialization/PathProcessor.cs @@ -11,7 +11,7 @@ namespace SabreTools.Serialization /// /// Path to open as a stream /// Stream representing the file, null on error - public static Stream? OpenStream(string? path) + public static Stream? OpenStream(string? path, bool skipCompression = false) { try { @@ -26,11 +26,11 @@ namespace SabreTools.Serialization string ext = Path.GetExtension(path).TrimStart('.'); // Determine what we do based on the extension - if (string.Equals(ext, "gz", StringComparison.OrdinalIgnoreCase)) + if (!skipCompression && string.Equals(ext, "gz", StringComparison.OrdinalIgnoreCase)) { return new GZipStream(stream, CompressionMode.Decompress); } - else if (string.Equals(ext, "zip", StringComparison.OrdinalIgnoreCase)) + else if (!skipCompression && string.Equals(ext, "zip", StringComparison.OrdinalIgnoreCase)) { // TODO: Support zip-compressed files return null;