using SabreTools.Data.Models.OperaFS; using SabreTools.Matching; namespace SabreTools.Data.Extensions { public static class OperaFSExtensions { /// /// Compare two DirectoryDescriptor objects /// /// The provided DirectoryDescriptor /// The DirectoryDescriptor to compare against /// True if all fields are equal, otherwise false 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; } /// /// Compare two DirectoryRecord objects /// /// The provided DirectoryRecord /// The DirectoryRecord to compare against /// True if all fields are equal, otherwise false 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; } } }