mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Structs] Add new structs for future use
This commit is contained in:
@@ -3,22 +3,136 @@ using System.Collections.Generic;
|
||||
|
||||
namespace SabreTools.Helper
|
||||
{
|
||||
#region Hash-to-Dat structs [Currently Unused]
|
||||
|
||||
/* Thought experiment
|
||||
|
||||
So, here's a connundrum: Should the internal structure of how DATs work (down to the hash level) mirror
|
||||
how people see it (Dat to multiple games, game to multiple roms, rom to single hash) or
|
||||
should it more closely mirror real life (Hash to multiple roms, rom to multiple games, game to single DAT)
|
||||
|
||||
If I use the "how people see it":
|
||||
Things are pretty much how they are now with redundant data and the like
|
||||
It makes sense to write things out to file, though. And life is easier when output is easier.
|
||||
No code changes (big plus!)
|
||||
|
||||
If I use the "how it is":
|
||||
Less data is likely to be mirrored
|
||||
Refs to DAT files are possible so that there aren't duplicates
|
||||
A lot of code will have to change...
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding and processing Hash data (NEW SYSTEM)
|
||||
/// </summary>
|
||||
public struct HashData
|
||||
{
|
||||
public long Size;
|
||||
public string CRC;
|
||||
public string MD5;
|
||||
public string SHA1;
|
||||
public List<RomData> Roms;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding and processing Rom data (NEW SYSTEM)
|
||||
/// </summary>
|
||||
public struct RomData
|
||||
{
|
||||
public string Name;
|
||||
public ItemType Type;
|
||||
public bool Nodump;
|
||||
public string Date;
|
||||
public List<MachineData> Machines;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding and processing Game/Machine data (NEW SYSTEM)
|
||||
/// </summary>
|
||||
public struct MachineData
|
||||
{
|
||||
public string Name;
|
||||
public string Comment;
|
||||
public string Description;
|
||||
public string Year;
|
||||
public string Manufacturer;
|
||||
public string RomOf;
|
||||
public string CloneOf;
|
||||
public string SampleOf;
|
||||
public string SourceFile;
|
||||
public bool IsBios;
|
||||
public string Board;
|
||||
public string RebuildTo;
|
||||
public bool TorrentZipped;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding and processing DAT data (NEW SYSTEM)
|
||||
/// </summary>
|
||||
public struct DatData
|
||||
{
|
||||
// Data common to most DAT types
|
||||
public string FileName;
|
||||
public string Name;
|
||||
public string Description;
|
||||
public string RootDir;
|
||||
public string Category;
|
||||
public string Version;
|
||||
public string Date;
|
||||
public string Author;
|
||||
public string Email;
|
||||
public string Homepage;
|
||||
public string Url;
|
||||
public string Comment;
|
||||
public string Header;
|
||||
public string Type; // Generally only used for SuperDAT
|
||||
public ForceMerging ForceMerging;
|
||||
public ForceNodump ForceNodump;
|
||||
public ForcePacking ForcePacking;
|
||||
public OutputFormat OutputFormat;
|
||||
public bool MergeRoms;
|
||||
|
||||
// Data specific to the Miss DAT type
|
||||
public bool UseGame;
|
||||
public string Prefix;
|
||||
public string Postfix;
|
||||
public bool Quotes;
|
||||
public string RepExt;
|
||||
public string AddExt;
|
||||
public bool GameName;
|
||||
public bool Romba;
|
||||
public bool? XSV; // true for tab-deliminated output, false for comma-deliminated output
|
||||
|
||||
// Statistical data related to the DAT
|
||||
public long RomCount;
|
||||
public long DiskCount;
|
||||
public long TotalSize;
|
||||
public long CRCCount;
|
||||
public long MD5Count;
|
||||
public long SHA1Count;
|
||||
public long NodumpCount;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dat-to-Hash structs
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding and processing hash data
|
||||
/// </summary>
|
||||
public struct HashData : IEquatable<HashData>
|
||||
public struct Hash : IEquatable<Hash>
|
||||
{
|
||||
public long Size;
|
||||
public string CRC;
|
||||
public string MD5;
|
||||
public string SHA1;
|
||||
|
||||
public bool Equals(HashData other)
|
||||
public bool Equals(Hash other)
|
||||
{
|
||||
return this.Equals(other, false);
|
||||
}
|
||||
|
||||
public bool Equals(HashData other, bool IsDisk)
|
||||
public bool Equals(Hash other, bool IsDisk)
|
||||
{
|
||||
bool equals = false;
|
||||
|
||||
@@ -49,7 +163,7 @@ namespace SabreTools.Helper
|
||||
public Machine Machine;
|
||||
public string Name;
|
||||
public ItemType Type;
|
||||
public HashData HashData;
|
||||
public Hash HashData;
|
||||
public DupeType Dupe;
|
||||
public bool Nodump;
|
||||
public string Date;
|
||||
@@ -57,9 +171,6 @@ namespace SabreTools.Helper
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
Logger temp = new Logger(false, "");
|
||||
temp.Start();
|
||||
|
||||
int ret = 0;
|
||||
|
||||
try
|
||||
@@ -70,7 +181,7 @@ namespace SabreTools.Helper
|
||||
{
|
||||
if (this.Name == comp.Name)
|
||||
{
|
||||
ret = (RomTools.IsDuplicate(this, comp, temp) ? 0 : 1);
|
||||
ret = (this.Equals(comp) ? 0 : 1);
|
||||
}
|
||||
ret = String.Compare(this.Name, comp.Name);
|
||||
}
|
||||
@@ -81,7 +192,6 @@ namespace SabreTools.Helper
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
temp.Close();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -278,6 +388,10 @@ namespace SabreTools.Helper
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Skipper structs
|
||||
|
||||
/// <summary>
|
||||
/// Intermediate struct for holding header skipper information
|
||||
/// </summary>
|
||||
@@ -313,4 +427,6 @@ namespace SabreTools.Helper
|
||||
public long? Size; // null is PO2, "power of 2" filesize
|
||||
public HeaderSkipTestFileOperator Operator;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ namespace SabreTools.Helper
|
||||
{
|
||||
Name = gamename,
|
||||
},
|
||||
HashData = new HashData
|
||||
HashData = new Hash
|
||||
{
|
||||
Size = (size == 0 ? reader.Entry.Size : size),
|
||||
CRC = (crc == "" ? reader.Entry.Crc.ToString("X").ToLowerInvariant() : crc),
|
||||
@@ -626,7 +626,7 @@ namespace SabreTools.Helper
|
||||
Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
||||
},
|
||||
Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
||||
HashData = new HashData
|
||||
HashData = new Hash
|
||||
{
|
||||
Size = extractedsize,
|
||||
CRC = gzcrc.ToLowerInvariant(),
|
||||
|
||||
@@ -574,7 +574,7 @@ namespace SabreTools.Helper
|
||||
Description = rominfo[4],
|
||||
},
|
||||
Name = rominfo[5],
|
||||
HashData = new HashData
|
||||
HashData = new Hash
|
||||
{
|
||||
CRC = rominfo[6].ToLowerInvariant(),
|
||||
Size = Int64.Parse(rominfo[7]),
|
||||
@@ -686,7 +686,7 @@ namespace SabreTools.Helper
|
||||
Name = tempgame,
|
||||
Description = tempgame,
|
||||
},
|
||||
HashData = new HashData
|
||||
HashData = new Hash
|
||||
{
|
||||
Size = -1,
|
||||
CRC = "null",
|
||||
@@ -1136,7 +1136,7 @@ namespace SabreTools.Helper
|
||||
},
|
||||
Name = subreader.GetAttribute("name"),
|
||||
Type = (subreader.Name.ToLowerInvariant() == "disk" ? ItemType.Disk : ItemType.Rom),
|
||||
HashData = new HashData
|
||||
HashData = new Hash
|
||||
{
|
||||
Size = size,
|
||||
CRC = crc,
|
||||
@@ -1195,7 +1195,7 @@ namespace SabreTools.Helper
|
||||
Name = tempname,
|
||||
Description = tempname,
|
||||
},
|
||||
HashData = new HashData
|
||||
HashData = new Hash
|
||||
{
|
||||
Size = -1,
|
||||
CRC = "null",
|
||||
@@ -1375,7 +1375,7 @@ namespace SabreTools.Helper
|
||||
},
|
||||
Name = xtr.GetAttribute("name"),
|
||||
Type = (xtr.GetAttribute("type").ToLowerInvariant() == "disk" ? ItemType.Disk : ItemType.Rom),
|
||||
HashData = new HashData
|
||||
HashData = new Hash
|
||||
{
|
||||
Size = size,
|
||||
CRC = crc,
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace SabreTools.Helper
|
||||
{
|
||||
Name = Path.GetFileName(input),
|
||||
Type = ItemType.Rom,
|
||||
HashData = new HashData
|
||||
HashData = new Hash
|
||||
{
|
||||
Size = (new FileInfo(input)).Length,
|
||||
CRC = string.Empty,
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace SabreTools
|
||||
"") + actualroot :
|
||||
actualroot),
|
||||
},
|
||||
HashData = new HashData
|
||||
HashData = new Hash
|
||||
{
|
||||
Size = -1,
|
||||
CRC = "null",
|
||||
@@ -220,7 +220,7 @@ namespace SabreTools
|
||||
"") + actualroot :
|
||||
actualroot),
|
||||
},
|
||||
HashData = new HashData
|
||||
HashData = new Hash
|
||||
{
|
||||
Size = -1,
|
||||
CRC = "null",
|
||||
|
||||
Reference in New Issue
Block a user