mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-02-04 05:36:12 +00:00
Add placeholder SFFS wrapper
This commit is contained in:
90
SabreTools.Serialization/Wrappers/SFFS.cs
Normal file
90
SabreTools.Serialization/Wrappers/SFFS.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System.IO;
|
||||
|
||||
namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// TODO: Hook up the models to a proper deserializer
|
||||
public class SFFS : WrapperBase
|
||||
{
|
||||
#region Descriptive Properties
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string DescriptionString => "StarForce File System";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(byte[] data) : base(data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(byte[] data, int offset) : base(data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(byte[] data, int offset, int length) : base(data, offset, length) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(Stream data) : base(data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(Stream data, long offset) : base(data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(Stream data, long offset, long length) : base(data, offset, length) { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a SFFS file from a byte array and offset
|
||||
/// </summary>
|
||||
/// <param name="data">Byte array representing the archive</param>
|
||||
/// <param name="offset">Offset within the array to parse</param>
|
||||
/// <returns>A SFFS wrapper on success, null on failure</returns>
|
||||
public static SFFS? Create(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null || data.Length == 0)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and use that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return Create(dataStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a SFFS file (or derived format) from a Stream
|
||||
/// </summary>
|
||||
/// <param name="data">Stream representing the archive</param>
|
||||
/// <returns>A SFFS wrapper on success, null on failure</returns>
|
||||
public static SFFS? Create(Stream? data)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
return new SFFS(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region JSON Export
|
||||
|
||||
#if NETCOREAPP
|
||||
/// <inheritdoc/>
|
||||
public override string ExportJSON() => throw new System.NotImplementedException();
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
WrapperType.RealArcadeMezzanine => null,// TODO: Implement wrapper
|
||||
WrapperType.SecuROMDFA => SecuROMDFA.Create(data),
|
||||
WrapperType.SevenZip => SevenZip.Create(data),
|
||||
WrapperType.SFFS => null,// TODO: Implement wrapper
|
||||
WrapperType.SFFS => SFFS.Create(data),
|
||||
WrapperType.SGA => SGA.Create(data),
|
||||
WrapperType.TapeArchive => TapeArchive.Create(data),
|
||||
WrapperType.Textfile => null,// TODO: Implement wrapper
|
||||
|
||||
@@ -195,7 +195,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// StarForce FileSystem file
|
||||
/// </summary>
|
||||
/// <remarks>Currently has no IWrapper implementation</remarks>
|
||||
SFFS,
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user