Redumper skeleton support (#32)

* Skeleton support

* hide ISO extract

* Return true

* Don't inherit ISO9660

* fix

* fix2

* Skeleton
This commit is contained in:
Deterous
2025-10-31 00:46:45 +09:00
committed by GitHub
parent 9db2d2ca05
commit f07bd07cce
3 changed files with 120 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ namespace SabreTools.Serialization
WrapperType.RealArcadeMezzanine => RealArcadeMezzanine.Create(data),
WrapperType.SecuROMDFA => SecuROMDFA.Create(data),
WrapperType.SevenZip => SevenZip.Create(data),
WrapperType.Skeleton => Skeleton.Create(data),
WrapperType.SFFS => SFFS.Create(data),
WrapperType.SGA => SGA.Create(data),
WrapperType.TapeArchive => TapeArchive.Create(data),
@@ -669,6 +670,13 @@ namespace SabreTools.Serialization
#endregion
#region Skeleton
if (extension.Equals("skeleton", StringComparison.OrdinalIgnoreCase))
return WrapperType.Skeleton;
#endregion
// TODO: Use constants from Models here
#region TapeArchive

View File

@@ -0,0 +1,107 @@
using System.Collections.Generic;
using System.IO;
using SabreTools.Data.Models.ISO9660;
namespace SabreTools.Serialization.Wrappers
{
public class Skeleton : WrapperBase<Volume>
{
#region Descriptive Properties
/// <inheritdoc/>
public override string DescriptionString => "Redumper Skeleton";
#endregion
#region Extension Properties
/// <inheritdoc cref="Volume.SystemArea"/>
public byte[] SystemArea => Model.SystemArea ?? [];
/// <inheritdoc cref="Volume.VolumeDescriptorSet"/>
public VolumeDescriptor[] VolumeDescriptorSet => Model.VolumeDescriptorSet ?? [];
/// <inheritdoc cref="Volume.PathTableGroups"/>
public PathTableGroup[] PathTableGroups => Model.PathTableGroups ?? [];
/// <inheritdoc cref="Volume.DirectoryDescriptors"/>
public Dictionary<int, FileExtent> DirectoryDescriptors => Model.DirectoryDescriptors ?? [];
#endregion
#region Constructors
/// <inheritdoc/>
public Skeleton(Volume model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public Skeleton(Volume model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public Skeleton(Volume model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public Skeleton(Volume model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public Skeleton(Volume model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public Skeleton(Volume model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an Skeleton Volume 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>An Skeleton Volume wrapper on success, null on failure</returns>
public static Skeleton? 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 an Skeleton Volume from a Stream
/// </summary>
/// <param name="data">Stream representing the archive</param>
/// <returns>An Skeleton Volume wrapper on success, null on failure</returns>
public static Skeleton? Create(Stream? data)
{
// If the data is invalid
if (data == null || !data.CanRead)
return null;
try
{
// Cache the current offset
long currentOffset = data.Position;
var model = new Readers.ISO9660().Deserialize(data);
if (model == null)
return null;
return new Skeleton(model, data, currentOffset);
}
catch
{
return null;
}
}
#endregion
}
}

View File

@@ -207,6 +207,11 @@ namespace SabreTools.Serialization.Wrappers
/// </summary>
SGA,
/// <summary>
/// Redumper skeleton (Wiped ISO9660 disc image)
/// </summary>
Skeleton,
/// <summary>
/// Tape archive
/// </summary>