mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
Add Opera FileSystem support (#90)
* Add Opera FileSystem support * Fix tests
This commit is contained in:
@@ -107,7 +107,7 @@ namespace SabreTools.Data.Extensions
|
||||
/// <summary>
|
||||
/// Creates a stream that provides only the user data of a CDROM stream
|
||||
/// </summary>
|
||||
public class ISO9660Stream : Stream
|
||||
public class UserDataStream : Stream
|
||||
{
|
||||
// Base CDROM stream (2352-byte sector)
|
||||
private readonly Stream _baseStream;
|
||||
@@ -121,7 +121,7 @@ namespace SabreTools.Data.Extensions
|
||||
private long _isoSectorSize = Constants.Mode1DataSize;
|
||||
#pragma warning restore IDE0044
|
||||
|
||||
public ISO9660Stream(Stream inputStream)
|
||||
public UserDataStream(Stream inputStream)
|
||||
{
|
||||
if (!inputStream.CanSeek || !inputStream.CanRead)
|
||||
throw new ArgumentException("Stream must be readable and seekable.", nameof(inputStream));
|
||||
|
||||
79
SabreTools.Data.Extensions/OperaFSExtensions.cs
Normal file
79
SabreTools.Data.Extensions/OperaFSExtensions.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using SabreTools.Data.Models.OperaFS;
|
||||
using SabreTools.Matching;
|
||||
using SabreTools.Numerics;
|
||||
|
||||
namespace SabreTools.Data.Extensions
|
||||
{
|
||||
public static class OperaFSExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Compare two DirectoryDescriptor objects
|
||||
/// </summary>
|
||||
/// <param name="dir1">The provided DirectoryDescriptor</param>
|
||||
/// <param name="dir2">The DirectoryDescriptor to compare against</param>
|
||||
/// <returns>True if all fields are equal, otherwise false</returns>
|
||||
public static bool EqualsExactly(this DirectoryDescriptor dir1, DirectoryDescriptor dir2)
|
||||
{
|
||||
if (dir1.NextBlock != dir2.NextBlock)
|
||||
return false;
|
||||
if (dir1.PreviousBlock != dir2.PreviousBlock)
|
||||
return false;
|
||||
if (dir1.Flags != dir2.Flags)
|
||||
return false;
|
||||
if (dir1.FirstFreeByte != dir2.FirstFreeByte)
|
||||
return false;
|
||||
if (dir1.FirstEntryOffset != dir2.FirstEntryOffset)
|
||||
return false;
|
||||
if (dir1.DirectoryRecords.Length != dir2.DirectoryRecords.Length)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < dir1.DirectoryRecords.Length; i++)
|
||||
{
|
||||
if (!dir1.DirectoryRecords[i].EqualsExactly(dir2.DirectoryRecords[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare two DirectoryRecord objects
|
||||
/// </summary>
|
||||
/// <param name="dir1">The provided DirectoryRecord</param>
|
||||
/// <param name="dir2">The DirectoryRecord to compare against</param>
|
||||
/// <returns>True if all fields are equal, otherwise false</returns>
|
||||
public static bool EqualsExactly(this DirectoryRecord dr1, DirectoryRecord dr2)
|
||||
{
|
||||
if ((byte)dr1.DirectoryRecordFlags != (byte)dr2.DirectoryRecordFlags)
|
||||
return false;
|
||||
if (!dr1.UniqueIdentifier.EqualsExactly(dr2.UniqueIdentifier))
|
||||
return false;
|
||||
if (!dr1.Type.EqualsExactly(dr2.Type))
|
||||
return false;
|
||||
if (dr1.BlockSize != dr2.BlockSize)
|
||||
return false;
|
||||
if (dr1.ByteCount != dr2.ByteCount)
|
||||
return false;
|
||||
if (dr1.BlockCount != dr2.BlockCount)
|
||||
return false;
|
||||
if (dr1.Burst != dr2.Burst)
|
||||
return false;
|
||||
if (dr1.Gap != dr2.Gap)
|
||||
return false;
|
||||
if (!dr1.Filename.EqualsExactly(dr2.Filename))
|
||||
return false;
|
||||
if (dr1.LastAvatarIndex != dr2.LastAvatarIndex)
|
||||
return false;
|
||||
if (dr1.AvatarList.Length != dr2.AvatarList.Length)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < dr1.AvatarList.Length; i++)
|
||||
{
|
||||
if (dr1.AvatarList[i] != dr2.AvatarList[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user