diff --git a/ExtractionTool/Program.cs b/ExtractionTool/Program.cs index 7ce8aca2..1fc046f6 100644 --- a/ExtractionTool/Program.cs +++ b/ExtractionTool/Program.cs @@ -101,12 +101,7 @@ namespace ExtractionTool { // 7-zip case SevenZip sz: -#if NET20 || NET35 || NET40 || NET452 - Console.WriteLine("Extraction is not supported for this framework!"); - Console.WriteLine(); -#else sz.Extract(outputDirectory, includeDebug); -#endif break; // BFPK archive @@ -126,12 +121,7 @@ namespace ExtractionTool // CFB case CFB cfb: -#if NET20 || NET35 - Console.WriteLine("Extraction is not supported for this framework!"); - Console.WriteLine(); -#else cfb.Extract(outputDirectory, includeDebug); -#endif break; // GCF @@ -176,15 +166,9 @@ namespace ExtractionTool MicrosoftCabinet.ExtractSet(file, outputDirectory, includeDebug); break; - // MoPaQ (MPQ) archive -- Reimplement + // MoPaQ (MPQ) archive case MoPaQ mpq: -#if NET20 || NET35 || !(WINX86 || WINX64) - Console.WriteLine("Extraction is not supported for this framework!"); - Console.WriteLine(); -#else - Console.WriteLine("Extraction needs to be reimplemented for this framework!"); - Console.WriteLine(); -#endif + mpq.Extract(outputDirectory, includeDebug); break; // New Executable @@ -204,12 +188,7 @@ namespace ExtractionTool // PKZIP case PKZIP pkzip: -#if NET20 || NET35 || NET40 || NET452 - Console.WriteLine("Extraction is not supported for this framework!"); - Console.WriteLine(); -#else pkzip.Extract(outputDirectory, includeDebug); -#endif break; // Portable Executable @@ -224,12 +203,7 @@ namespace ExtractionTool // RAR case RAR rar: -#if NET20 || NET35 || NET40 || NET452 - Console.WriteLine("Extraction is not supported for this framework!"); - Console.WriteLine(); -#else rar.Extract(outputDirectory, includeDebug); -#endif break; // SGA @@ -259,12 +233,7 @@ namespace ExtractionTool // xz case XZ xz: -#if NET20 || NET35 || NET40 || NET452 - Console.WriteLine("Extraction is not supported for this framework!"); - Console.WriteLine(); -#else xz.Extract(outputDirectory, includeDebug); -#endif break; // XZP diff --git a/SabreTools.Serialization/Wrappers/MoPaQ.cs b/SabreTools.Serialization/Wrappers/MoPaQ.cs index 0329f0aa..7ba5eb42 100644 --- a/SabreTools.Serialization/Wrappers/MoPaQ.cs +++ b/SabreTools.Serialization/Wrappers/MoPaQ.cs @@ -1,8 +1,10 @@ -using System.IO; +using System; +using System.IO; +using SabreTools.Serialization.Interfaces; namespace SabreTools.Serialization.Wrappers { - public partial class MoPaQ : WrapperBase + public partial class MoPaQ : WrapperBase, IExtractable { #region Descriptive Properties @@ -78,5 +80,24 @@ namespace SabreTools.Serialization.Wrappers } #endregion + + #region Extraction + + /// + /// TODO: Reimplement extraction based on StormLibSharp + public bool Extract(string outputDirectory, bool includeDebug) + { +#if NET20 || NET35 || !(WINX86 || WINX64) + Console.WriteLine("Extraction is not supported for this framework!"); + Console.WriteLine(); + return false; +#else + Console.WriteLine("Extraction needs to be reimplemented for this framework!"); + Console.WriteLine(); + return false; +#endif + } + + #endregion } } diff --git a/SabreTools.Serialization/Wrappers/PKZIP.cs b/SabreTools.Serialization/Wrappers/PKZIP.cs index 8d5c2c1e..16dd96ea 100644 --- a/SabreTools.Serialization/Wrappers/PKZIP.cs +++ b/SabreTools.Serialization/Wrappers/PKZIP.cs @@ -203,6 +203,8 @@ namespace SabreTools.Serialization.Wrappers return false; } #else + Console.WriteLine("Extraction is not supported for this framework!"); + Console.WriteLine(); return false; #endif } diff --git a/SabreTools.Serialization/Wrappers/RAR.cs b/SabreTools.Serialization/Wrappers/RAR.cs index 6a5ff530..4ba71d3a 100644 --- a/SabreTools.Serialization/Wrappers/RAR.cs +++ b/SabreTools.Serialization/Wrappers/RAR.cs @@ -133,6 +133,8 @@ namespace SabreTools.Serialization.Wrappers return false; } #else + Console.WriteLine("Extraction is not supported for this framework!"); + Console.WriteLine(); return false; #endif } diff --git a/SabreTools.Serialization/Wrappers/SevenZip.cs b/SabreTools.Serialization/Wrappers/SevenZip.cs index c08debf6..ce409251 100644 --- a/SabreTools.Serialization/Wrappers/SevenZip.cs +++ b/SabreTools.Serialization/Wrappers/SevenZip.cs @@ -135,6 +135,8 @@ namespace SabreTools.Serialization.Wrappers return false; } #else + Console.WriteLine("Extraction is not supported for this framework!"); + Console.WriteLine(); return false; #endif } diff --git a/SabreTools.Serialization/Wrappers/XZ.cs b/SabreTools.Serialization/Wrappers/XZ.cs index 8dd7a6d5..9e7b6b9d 100644 --- a/SabreTools.Serialization/Wrappers/XZ.cs +++ b/SabreTools.Serialization/Wrappers/XZ.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using SabreTools.Serialization.Interfaces; #if NET462_OR_GREATER || NETCOREAPP @@ -87,17 +88,19 @@ namespace SabreTools.Serialization.Wrappers /// public bool Extract(string outputDirectory, bool includeDebug) { -#if NET462_OR_GREATER || NETCOREAPP if (_dataSource == null || !_dataSource.CanRead) return false; +#if NET462_OR_GREATER || NETCOREAPP try { // Try opening the stream using var xzFile = new XZStream(_dataSource); // Ensure directory separators are consistent - string filename = System.Guid.NewGuid().ToString(); + string filename = Filename != null + ? Path.GetFileNameWithoutExtension(Filename) + : Guid.NewGuid().ToString(); if (Path.DirectorySeparatorChar == '\\') filename = filename.Replace('/', '\\'); else if (Path.DirectorySeparatorChar == '/') @@ -116,12 +119,14 @@ namespace SabreTools.Serialization.Wrappers return true; } - catch (System.Exception ex) + catch (Exception ex) { - if (includeDebug) System.Console.Error.WriteLine(ex); + if (includeDebug) Console.Error.WriteLine(ex); return false; } #else + Console.WriteLine("Extraction is not supported for this framework!"); + Console.WriteLine(); return false; #endif }