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 ///