diff --git a/SabreTools.Serialization/Deserializers/GZip.cs b/SabreTools.Serialization/Deserializers/GZip.cs new file mode 100644 index 00000000..59d411f0 --- /dev/null +++ b/SabreTools.Serialization/Deserializers/GZip.cs @@ -0,0 +1,17 @@ +using System.IO; +using SabreTools.Models.GZIP; + +namespace SabreTools.Serialization.Deserializers +{ + public class GZip : BaseBinaryDeserializer + { + /// + protected override bool SkipCompression => true; + + /// + public override Archive? Deserialize(Stream? data) + { + throw new System.NotImplementedException(); + } + } +} diff --git a/SabreTools.Serialization/Deserializers/TapeArchive.cs b/SabreTools.Serialization/Deserializers/TapeArchive.cs new file mode 100644 index 00000000..089b7f82 --- /dev/null +++ b/SabreTools.Serialization/Deserializers/TapeArchive.cs @@ -0,0 +1,19 @@ +using System.IO; +using SabreTools.Models.TAR; + +namespace SabreTools.Serialization.Deserializers +{ + public class TapeArchive : BaseBinaryDeserializer + { + /// + protected override bool SkipCompression => true; + + /// + public override Archive? Deserialize(Stream? data) + { + throw new System.NotImplementedException(); + } + + + } +} diff --git a/SabreTools.Serialization/Wrappers/GZip.cs b/SabreTools.Serialization/Wrappers/GZip.cs index fcc35791..b5f6e080 100644 --- a/SabreTools.Serialization/Wrappers/GZip.cs +++ b/SabreTools.Serialization/Wrappers/GZip.cs @@ -1,16 +1,12 @@ using System; using System.IO; using SabreTools.IO.Compression.Deflate; +using SabreTools.Models.GZIP; using SabreTools.Serialization.Interfaces; namespace SabreTools.Serialization.Wrappers { - /// - /// This is a shell wrapper; one that does not contain - /// any actual parsing. It is used as a placeholder for - /// types that typically do not have models. - /// - public class GZip : WrapperBase, IExtractable + public class GZip : WrapperBase, IExtractable { #region Descriptive Properties @@ -22,15 +18,15 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - public GZip(byte[]? data, int offset) - : base(data, offset) + public GZip(Archive? model, byte[]? data, int offset) + : base(model, data, offset) { // All logic is handled by the base class } /// - public GZip(Stream? data) - : base(data) + public GZip(Archive? model, Stream? data) + : base(model, data) { // All logic is handled by the base class } @@ -67,7 +63,18 @@ namespace SabreTools.Serialization.Wrappers if (data == null || !data.CanRead) return null; - return new GZip(data); + try + { + var model = Deserializers.GZip.DeserializeStream(data); + if (model == null) + return null; + + return new GZip(model, data); + } + catch + { + return null; + } } #endregion diff --git a/SabreTools.Serialization/Wrappers/TapeArchive.cs b/SabreTools.Serialization/Wrappers/TapeArchive.cs index bcc71ca0..597d858f 100644 --- a/SabreTools.Serialization/Wrappers/TapeArchive.cs +++ b/SabreTools.Serialization/Wrappers/TapeArchive.cs @@ -1,4 +1,5 @@ using System.IO; +using SabreTools.Models.TAR; using SabreTools.Serialization.Interfaces; #if NET462_OR_GREATER || NETCOREAPP using SharpCompress.Archives; @@ -7,12 +8,7 @@ using SharpCompress.Archives.Tar; namespace SabreTools.Serialization.Wrappers { - /// - /// This is a shell wrapper; one that does not contain - /// any actual parsing. It is used as a placeholder for - /// types that typically do not have models. - /// - public class TapeArchive : WrapperBase, IExtractable + public class TapeArchive : WrapperBase, IExtractable { #region Descriptive Properties @@ -23,16 +19,16 @@ namespace SabreTools.Serialization.Wrappers #region Constructors - //// - public TapeArchive(byte[]? data, int offset) - : base(data, offset) + /// + public TapeArchive(Archive? model, byte[]? data, int offset) + : base(model, data, offset) { // All logic is handled by the base class } /// - public TapeArchive(Stream? data) - : base(data) + public TapeArchive(Archive? model, Stream? data) + : base(model, data) { // All logic is handled by the base class } @@ -69,7 +65,18 @@ namespace SabreTools.Serialization.Wrappers if (data == null || !data.CanRead) return null; - return new TapeArchive(data); + try + { + var model = Deserializers.TapeArchive.DeserializeStream(data); + if (model == null) + return null; + + return new TapeArchive(model, data); + } + catch + { + return null; + } } #endregion