From 0aa25df88ff2bb27b660a03e11e88e150a64833b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 29 Jul 2025 11:48:34 -0400 Subject: [PATCH] More graceful handling of MS-CAB sets --- .../Wrappers/MicrosoftCabinet.cs | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs index 7b1fdd87..d49f79c0 100644 --- a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs +++ b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs @@ -115,16 +115,23 @@ namespace SabreTools.Serialization.Wrappers /// /// Extract a cabinet set to an output directory, if possible /// + /// Stream representing one cabinet in the set /// Filename for one cabinet in the set /// Path to the output directory /// True to include debug data, false otherwise /// Indicates if all files were able to be extracted /// Will extract all items found in the set - public static bool ExtractSet(string filename, string outDir, bool includeDebug) + public static bool ExtractSet(Stream? stream, string filename, string outDir, bool includeDebug) { - // Get a wrapper for the set - var current = OpenSet(filename); - if (current?.Header == null) + // Get a wrapper for the set, if possible + MicrosoftCabinet? current; + if (File.Exists(filename)) + current = OpenSet(filename); + else + current = Create(stream); + + // Validate the header exists + if (current?.Model?.Header == null) return false; try @@ -146,6 +153,17 @@ namespace SabreTools.Serialization.Wrappers return true; } + /// + /// Extract a cabinet set to an output directory, if possible + /// + /// Filename for one cabinet in the set + /// Path to the output directory + /// True to include debug data, false otherwise + /// Indicates if all files were able to be extracted + /// Will extract all items found in the set + public static bool ExtractSet(string filename, string outDir, bool includeDebug) + => ExtractSet(stream: null, filename, outDir, includeDebug); + /// /// Extract a cabinet to an output directory, if possible ///