mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatItems/] Clean these up a bit
This commit is contained in:
@@ -2,84 +2,84 @@
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents generic archive files to be included in a set
|
||||
/// </summary>
|
||||
public class Archive : DatItem
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Represents generic archive files to be included in a set
|
||||
/// </summary>
|
||||
public class Archive : DatItem
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty Archive object
|
||||
/// </summary>
|
||||
public Archive()
|
||||
{
|
||||
_name = "";
|
||||
_itemType = ItemType.Archive;
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a default, empty Archive object
|
||||
/// </summary>
|
||||
public Archive()
|
||||
{
|
||||
this.Name = "";
|
||||
this.ItemType = ItemType.Archive;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
#region Cloning Methods
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new Archive()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
public override object Clone()
|
||||
{
|
||||
return new Archive()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
};
|
||||
}
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
#region Comparision Methods
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have an archive, return false
|
||||
if (_itemType != other.ItemType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have an archive, return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, treat it as an archive
|
||||
Archive newOther = (Archive)other;
|
||||
// Otherwise, treat it as an archive
|
||||
Archive newOther = (Archive)other;
|
||||
|
||||
// If the archive information matches
|
||||
return (_name == newOther.Name);
|
||||
}
|
||||
// If the archive information matches
|
||||
return (this.Name == newOther.Name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,109 +2,101 @@
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents which BIOS(es) is associated with a set
|
||||
/// </summary>
|
||||
public class BiosSet : DatItem
|
||||
{
|
||||
#region Private instance variables
|
||||
/// <summary>
|
||||
/// Represents which BIOS(es) is associated with a set
|
||||
/// </summary>
|
||||
public class BiosSet : DatItem
|
||||
{
|
||||
#region Publicly facing variables
|
||||
|
||||
private string _description;
|
||||
private bool? _default;
|
||||
/// <summary>
|
||||
/// Description of the BIOS
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Determine whether the BIOS is default
|
||||
/// </summary>
|
||||
public bool? Default { get; set; }
|
||||
|
||||
#region Publicly facing variables
|
||||
#endregion
|
||||
|
||||
public string Description
|
||||
{
|
||||
get { return _description; }
|
||||
set { _description = value; }
|
||||
}
|
||||
public bool? Default
|
||||
{
|
||||
get { return _default; }
|
||||
set { _default = value; }
|
||||
}
|
||||
#region Constructors
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Create a default, empty Sample object
|
||||
/// </summary>
|
||||
public BiosSet()
|
||||
{
|
||||
this.Name = "";
|
||||
this.ItemType = ItemType.BiosSet;
|
||||
}
|
||||
|
||||
#region Constructors
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty Sample object
|
||||
/// </summary>
|
||||
public BiosSet()
|
||||
{
|
||||
_name = "";
|
||||
_itemType = ItemType.BiosSet;
|
||||
}
|
||||
#region Cloning Methods
|
||||
|
||||
#endregion
|
||||
public override object Clone()
|
||||
{
|
||||
return new BiosSet()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
#region Cloning Methods
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new BiosSet()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
Description = this.Description,
|
||||
Default = this.Default,
|
||||
};
|
||||
}
|
||||
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
#endregion
|
||||
|
||||
Description = this.Description,
|
||||
Default = this.Default,
|
||||
};
|
||||
}
|
||||
#region Comparision Methods
|
||||
|
||||
#endregion
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a biosset, return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#region Comparision Methods
|
||||
// Otherwise, treat it as a biosset
|
||||
BiosSet newOther = (BiosSet)other;
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a biosset, return false
|
||||
if (_itemType != other.ItemType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// If the archive information matches
|
||||
return (this.Name == newOther.Name && this.Description == newOther.Description && this.Default == newOther.Default);
|
||||
}
|
||||
|
||||
// Otherwise, treat it as a biosset
|
||||
BiosSet newOther = (BiosSet)other;
|
||||
|
||||
// If the archive information matches
|
||||
return (_name == newOther.Name && _description == newOther.Description && _default == newOther.Default);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,84 +2,84 @@
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a blank set from an input DAT
|
||||
/// </summary>
|
||||
public class Blank : DatItem
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Represents a blank set from an input DAT
|
||||
/// </summary>
|
||||
public class Blank : DatItem
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty Archive object
|
||||
/// </summary>
|
||||
public Blank()
|
||||
{
|
||||
_name = "";
|
||||
_itemType = ItemType.Blank;
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a default, empty Archive object
|
||||
/// </summary>
|
||||
public Blank()
|
||||
{
|
||||
this.Name = "";
|
||||
this.ItemType = ItemType.Blank;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
#region Cloning Methods
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new Blank()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
public override object Clone()
|
||||
{
|
||||
return new Blank()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
};
|
||||
}
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
#region Comparision Methods
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a blank, return false
|
||||
if (_itemType != other.ItemType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a blank, return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, treat it as a
|
||||
Blank newOther = (Blank)other;
|
||||
// Otherwise, treat it as a
|
||||
Blank newOther = (Blank)other;
|
||||
|
||||
// If the archive information matches
|
||||
return (_machine == newOther._machine);
|
||||
}
|
||||
// If the archive information matches
|
||||
return (_machine == newOther._machine);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,227 +1,237 @@
|
||||
using System.Linq;
|
||||
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.FileTypes;
|
||||
using SabreTools.Library.Tools;
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Compressed Hunks of Data (CHD) formatted disks which use internal hashes
|
||||
/// </summary>
|
||||
public class Disk : DatItem
|
||||
{
|
||||
#region Private instance variables
|
||||
/// <summary>
|
||||
/// Represents Compressed Hunks of Data (CHD) formatted disks which use internal hashes
|
||||
/// </summary>
|
||||
public class Disk : DatItem
|
||||
{
|
||||
#region Private instance variables
|
||||
|
||||
// Disk information
|
||||
private byte[] _md5; // 16 bytes
|
||||
private byte[] _sha1; // 20 bytes
|
||||
private byte[] _sha256; // 32 bytes
|
||||
private byte[] _sha384; // 48 bytes
|
||||
private byte[] _sha512; // 64 bytes
|
||||
private string _merge;
|
||||
private string _region;
|
||||
private string _index;
|
||||
private bool? _writable;
|
||||
private ItemStatus _itemStatus;
|
||||
private bool? _optional;
|
||||
private byte[] _md5; // 16 bytes
|
||||
private byte[] _sha1; // 20 bytes
|
||||
private byte[] _sha256; // 32 bytes
|
||||
private byte[] _sha384; // 48 bytes
|
||||
private byte[] _sha512; // 64 bytes
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Publicly facing variables
|
||||
#region Publicly facing variables
|
||||
|
||||
// Disk information
|
||||
public string MD5
|
||||
{
|
||||
get { return _md5.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_md5); }
|
||||
set { _md5 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA1
|
||||
{
|
||||
get { return _sha1.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha1); }
|
||||
set { _sha1 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA256
|
||||
{
|
||||
get { return _sha256.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha256); }
|
||||
set { _sha256 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA384
|
||||
{
|
||||
get { return _sha384.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha384); }
|
||||
set { _sha384 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA512
|
||||
{
|
||||
get { return _sha512.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha512); }
|
||||
set { _sha512 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string MergeTag
|
||||
{
|
||||
get { return _merge; }
|
||||
set { _merge = value; }
|
||||
}
|
||||
public string Region
|
||||
{
|
||||
get { return _region; }
|
||||
set { _region = value; }
|
||||
}
|
||||
public string Index
|
||||
{
|
||||
get { return _index; }
|
||||
set { _index = value; }
|
||||
}
|
||||
public bool? Writable
|
||||
{
|
||||
get { return _writable; }
|
||||
set { _writable = value; }
|
||||
}
|
||||
public ItemStatus ItemStatus
|
||||
{
|
||||
get { return _itemStatus; }
|
||||
set { _itemStatus = value; }
|
||||
}
|
||||
public bool? Optional
|
||||
{
|
||||
get { return _optional; }
|
||||
set { _optional = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Data MD5 hash
|
||||
/// </summary>
|
||||
public string MD5
|
||||
{
|
||||
get { return _md5.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_md5); }
|
||||
set { _md5 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Data SHA-1 hash
|
||||
/// </summary>
|
||||
public string SHA1
|
||||
{
|
||||
get { return _sha1.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha1); }
|
||||
set { _sha1 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Data SHA-256 hash
|
||||
/// </summary>
|
||||
public string SHA256
|
||||
{
|
||||
get { return _sha256.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha256); }
|
||||
set { _sha256 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty Disk object
|
||||
/// </summary>
|
||||
public Disk()
|
||||
{
|
||||
_name = "";
|
||||
_itemType = ItemType.Disk;
|
||||
_dupeType = 0x00;
|
||||
_itemStatus = ItemStatus.None;
|
||||
}
|
||||
/// <summary>
|
||||
/// Data SHA-384 hash
|
||||
/// </summary>
|
||||
public string SHA384
|
||||
{
|
||||
get { return _sha384.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha384); }
|
||||
set { _sha384 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a Rom object from a BaseFile
|
||||
/// </summary>
|
||||
/// <param name="baseFile"></param>
|
||||
public Disk(BaseFile baseFile)
|
||||
{
|
||||
_name = baseFile.Filename;
|
||||
_md5 = baseFile.MD5;
|
||||
_sha1 = baseFile.SHA1;
|
||||
_sha256 = baseFile.SHA256;
|
||||
_sha384 = baseFile.SHA384;
|
||||
_sha512 = baseFile.SHA512;
|
||||
/// <summary>
|
||||
/// Data SHA-512 hash
|
||||
/// </summary>
|
||||
public string SHA512
|
||||
{
|
||||
get { return _sha512.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha512); }
|
||||
set { _sha512 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
_itemType = ItemType.Disk;
|
||||
_dupeType = 0x00;
|
||||
_itemStatus = ItemStatus.None;
|
||||
}
|
||||
/// <summary>
|
||||
/// Disk name to merge from parent
|
||||
/// </summary>
|
||||
public string MergeTag { get; set; }
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Disk region
|
||||
/// </summary>
|
||||
public string Region { get; set; }
|
||||
|
||||
#region Cloning Methods
|
||||
/// <summary>
|
||||
/// Disk index
|
||||
/// </summary>
|
||||
public string Index { get; set; }
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new Disk()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
/// <summary>
|
||||
/// Disk writable flag
|
||||
/// </summary>
|
||||
public bool? Writable { get; set; }
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
/// <summary>
|
||||
/// Disk dump status
|
||||
/// </summary>
|
||||
public ItemStatus ItemStatus { get; set; }
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
/// <summary>
|
||||
/// Determine if the disk is optional in the set
|
||||
/// </summary>
|
||||
public bool? Optional { get; set; }
|
||||
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
#endregion
|
||||
|
||||
_md5 = this._md5,
|
||||
_sha1 = this._sha1,
|
||||
_sha256 = this._sha256,
|
||||
_sha384 = this._sha384,
|
||||
_sha512 = this._sha512,
|
||||
ItemStatus = this.ItemStatus,
|
||||
};
|
||||
}
|
||||
#region Constructors
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Create a default, empty Disk object
|
||||
/// </summary>
|
||||
public Disk()
|
||||
{
|
||||
this.Name = "";
|
||||
this.ItemType = ItemType.Disk;
|
||||
this.DupeType = 0x00;
|
||||
this.ItemStatus = ItemStatus.None;
|
||||
}
|
||||
|
||||
#region Comparision Methods
|
||||
/// <summary>
|
||||
/// Create a Rom object from a BaseFile
|
||||
/// </summary>
|
||||
/// <param name="baseFile"></param>
|
||||
public Disk(BaseFile baseFile)
|
||||
{
|
||||
this.Name = baseFile.Filename;
|
||||
_md5 = baseFile.MD5;
|
||||
_sha1 = baseFile.SHA1;
|
||||
_sha256 = baseFile.SHA256;
|
||||
_sha384 = baseFile.SHA384;
|
||||
_sha512 = baseFile.SHA512;
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
bool dupefound = false;
|
||||
this.ItemType = ItemType.Disk;
|
||||
this.DupeType = 0x00;
|
||||
this.ItemStatus = ItemStatus.None;
|
||||
}
|
||||
|
||||
// If we don't have a rom, return false
|
||||
if (_itemType != other.ItemType)
|
||||
{
|
||||
return dupefound;
|
||||
}
|
||||
#endregion
|
||||
|
||||
// Otherwise, treat it as a rom
|
||||
Disk newOther = (Disk)other;
|
||||
#region Cloning Methods
|
||||
|
||||
// If all hashes are empty but they're both nodump and the names match, then they're dupes
|
||||
if ((this._itemStatus == ItemStatus.Nodump && newOther._itemStatus == ItemStatus.Nodump)
|
||||
&& (this._name == newOther._name)
|
||||
&& (this._md5.IsNullOrWhiteSpace() && newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() && newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() && newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() && newOther._sha384.IsNullOrWhiteSpace())
|
||||
&& (this._sha512.IsNullOrWhiteSpace() && newOther._sha512.IsNullOrWhiteSpace()))
|
||||
{
|
||||
dupefound = true;
|
||||
}
|
||||
public override object Clone()
|
||||
{
|
||||
return new Disk()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
// If we can determine that the disks have no non-empty hashes in common, we return false
|
||||
else if ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace())
|
||||
&& (this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()))
|
||||
{
|
||||
dupefound = false;
|
||||
}
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
// Otherwise if we get a partial match
|
||||
else if (((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
&& ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
&& ((this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512)))
|
||||
{
|
||||
dupefound = true;
|
||||
}
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
return dupefound;
|
||||
}
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
|
||||
#endregion
|
||||
}
|
||||
_md5 = this._md5,
|
||||
_sha1 = this._sha1,
|
||||
_sha256 = this._sha256,
|
||||
_sha384 = this._sha384,
|
||||
_sha512 = this._sha512,
|
||||
ItemStatus = this.ItemStatus,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
bool dupefound = false;
|
||||
|
||||
// If we don't have a rom, return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
{
|
||||
return dupefound;
|
||||
}
|
||||
|
||||
// Otherwise, treat it as a rom
|
||||
Disk newOther = (Disk)other;
|
||||
|
||||
// If all hashes are empty but they're both nodump and the names match, then they're dupes
|
||||
if ((this.ItemStatus == ItemStatus.Nodump && newOther.ItemStatus == ItemStatus.Nodump)
|
||||
&& (this.Name == newOther.Name)
|
||||
&& (this._md5.IsNullOrWhiteSpace() && newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() && newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() && newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() && newOther._sha384.IsNullOrWhiteSpace())
|
||||
&& (this._sha512.IsNullOrWhiteSpace() && newOther._sha512.IsNullOrWhiteSpace()))
|
||||
{
|
||||
dupefound = true;
|
||||
}
|
||||
|
||||
// If we can determine that the disks have no non-empty hashes in common, we return false
|
||||
else if ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace())
|
||||
&& (this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()))
|
||||
{
|
||||
dupefound = false;
|
||||
}
|
||||
|
||||
// Otherwise if we get a partial match
|
||||
else if (((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
&& ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
&& ((this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512)))
|
||||
{
|
||||
dupefound = true;
|
||||
}
|
||||
|
||||
return dupefound;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,131 +2,121 @@
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents release information about a set
|
||||
/// </summary>
|
||||
public class Release : DatItem
|
||||
{
|
||||
#region Private instance variables
|
||||
/// <summary>
|
||||
/// Represents release information about a set
|
||||
/// </summary>
|
||||
public class Release : DatItem
|
||||
{
|
||||
#region Publicly facing variables
|
||||
|
||||
private string _region;
|
||||
private string _language;
|
||||
private string _date;
|
||||
private bool? _default;
|
||||
/// <summary>
|
||||
/// Release region(s)
|
||||
/// </summary>
|
||||
public string Region { get; set; }
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Release language(s)
|
||||
/// </summary>
|
||||
public string Language { get; set; }
|
||||
|
||||
#region Publicly facing variables
|
||||
/// <summary>
|
||||
/// Date of release
|
||||
/// </summary>
|
||||
public string Date { get; set; }
|
||||
|
||||
public string Region
|
||||
{
|
||||
get { return _region; }
|
||||
set { _region = value; }
|
||||
}
|
||||
public string Language
|
||||
{
|
||||
get { return _language; }
|
||||
set { _language = value; }
|
||||
}
|
||||
public string Date
|
||||
{
|
||||
get { return _date; }
|
||||
set { _date = value; }
|
||||
}
|
||||
public bool? Default
|
||||
{
|
||||
get { return _default; }
|
||||
set { _default = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Default release, if applicable
|
||||
/// </summary>
|
||||
public bool? Default { get; set; }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty Release object
|
||||
/// </summary>
|
||||
public Release()
|
||||
{
|
||||
_name = "";
|
||||
_itemType = ItemType.Release;
|
||||
_region = "";
|
||||
_language = "";
|
||||
_date = "";
|
||||
_default = null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a default, empty Release object
|
||||
/// </summary>
|
||||
public Release()
|
||||
{
|
||||
this.Name = "";
|
||||
this.ItemType = ItemType.Release;
|
||||
this.Region = "";
|
||||
this.Language = "";
|
||||
this.Date = "";
|
||||
this.Default = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
#region Cloning Methods
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new Release()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
public override object Clone()
|
||||
{
|
||||
return new Release()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
|
||||
Region = this.Region,
|
||||
Language = this.Language,
|
||||
Date = this.Date,
|
||||
Default = this.Default,
|
||||
};
|
||||
}
|
||||
Region = this.Region,
|
||||
Language = this.Language,
|
||||
Date = this.Date,
|
||||
Default = this.Default,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
#region Comparision Methods
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a release return false
|
||||
if (_itemType != other.ItemType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a release return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, treat it as a reease
|
||||
Release newOther = (Release)other;
|
||||
// Otherwise, treat it as a reease
|
||||
Release newOther = (Release)other;
|
||||
|
||||
// If the archive information matches
|
||||
return (_name == newOther.Name
|
||||
&& _region == newOther.Region
|
||||
&& _language == newOther.Language
|
||||
&& _date == newOther.Date
|
||||
&& _default == newOther.Default);
|
||||
}
|
||||
// If the archive information matches
|
||||
return (this.Name == newOther.Name
|
||||
&& this.Region == newOther.Region
|
||||
&& this.Language == newOther.Language
|
||||
&& this.Date == newOther.Date
|
||||
&& this.Default == newOther.Default);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,301 +1,313 @@
|
||||
using System.Linq;
|
||||
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.FileTypes;
|
||||
using SabreTools.Library.Tools;
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic file within a set
|
||||
/// </summary>
|
||||
public class Rom : DatItem
|
||||
{
|
||||
#region Private instance variables
|
||||
/// <summary>
|
||||
/// Represents a generic file within a set
|
||||
/// </summary>
|
||||
public class Rom : DatItem
|
||||
{
|
||||
#region Private instance variables
|
||||
|
||||
// Rom information
|
||||
private string _bios;
|
||||
private long _size;
|
||||
private byte[] _crc; // 8 bytes
|
||||
private byte[] _md5; // 16 bytes
|
||||
private byte[] _sha1; // 20 bytes
|
||||
private byte[] _sha256; // 32 bytes
|
||||
private byte[] _sha384; // 48 bytes
|
||||
private byte[] _sha512; // 64 bytes
|
||||
private string _merge;
|
||||
private string _region;
|
||||
private string _offset;
|
||||
private string _date;
|
||||
private ItemStatus _itemStatus;
|
||||
private bool? _optional;
|
||||
private byte[] _crc; // 8 bytes
|
||||
private byte[] _md5; // 16 bytes
|
||||
private byte[] _sha1; // 20 bytes
|
||||
private byte[] _sha256; // 32 bytes
|
||||
private byte[] _sha384; // 48 bytes
|
||||
private byte[] _sha512; // 64 bytes
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Publicly facing variables
|
||||
#region Publicly facing variables
|
||||
|
||||
// Rom information
|
||||
public string Bios
|
||||
{
|
||||
get { return _bios; }
|
||||
set { _bios = value; }
|
||||
}
|
||||
public long Size
|
||||
{
|
||||
get { return _size; }
|
||||
set { _size = value; }
|
||||
}
|
||||
public string CRC
|
||||
{
|
||||
get { return _crc.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_crc); }
|
||||
set { _crc = (value == "null" ? Constants.CRCZeroBytes : Utilities.StringToByteArray(value)); }
|
||||
}
|
||||
public string MD5
|
||||
{
|
||||
get { return _md5.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_md5); }
|
||||
set { _md5 = (value == "null" ? Constants.MD5ZeroBytes : Utilities.StringToByteArray(value)); }
|
||||
}
|
||||
public string SHA1
|
||||
{
|
||||
get { return _sha1.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha1); }
|
||||
set { _sha1 = (value == "null" ? Constants.SHA1ZeroBytes : Utilities.StringToByteArray(value)); }
|
||||
}
|
||||
public string SHA256
|
||||
{
|
||||
get { return _sha256.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha256); }
|
||||
set { _sha256 = (value == "null" ? Constants.SHA256ZeroBytes : Utilities.StringToByteArray(value)); }
|
||||
}
|
||||
public string SHA384
|
||||
{
|
||||
get { return _sha384.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha384); }
|
||||
set { _sha384 = (value == "null" ? Constants.SHA384ZeroBytes : Utilities.StringToByteArray(value)); }
|
||||
}
|
||||
public string SHA512
|
||||
{
|
||||
get { return _sha512.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha512); }
|
||||
set { _sha512 = (value == "null" ? Constants.SHA512ZeroBytes : Utilities.StringToByteArray(value)); }
|
||||
}
|
||||
public string MergeTag
|
||||
{
|
||||
get { return _merge; }
|
||||
set { _merge = value; }
|
||||
}
|
||||
public string Region
|
||||
{
|
||||
get { return _region; }
|
||||
set { _region = value; }
|
||||
}
|
||||
public string Offset
|
||||
{
|
||||
get { return _offset; }
|
||||
set { _offset = value; }
|
||||
}
|
||||
public string Date
|
||||
{
|
||||
get { return _date; }
|
||||
set { _date = value; }
|
||||
}
|
||||
public ItemStatus ItemStatus
|
||||
{
|
||||
get { return _itemStatus; }
|
||||
set { _itemStatus = value; }
|
||||
}
|
||||
public bool? Optional
|
||||
{
|
||||
get { return _optional; }
|
||||
set { _optional = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// What BIOS is required for this rom
|
||||
/// </summary>
|
||||
public string Bios { get; set; }
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Byte size of the rom
|
||||
/// </summary>
|
||||
public long Size { get; set; }
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// File CRC32 hash
|
||||
/// </summary>
|
||||
public string CRC
|
||||
{
|
||||
get { return _crc.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_crc); }
|
||||
set { _crc = (value == "null" ? Constants.CRCZeroBytes : Utilities.StringToByteArray(value)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty Rom object
|
||||
/// </summary>
|
||||
public Rom()
|
||||
{
|
||||
_name = "";
|
||||
_itemType = ItemType.Rom;
|
||||
_dupeType = 0x00;
|
||||
_itemStatus = ItemStatus.None;
|
||||
_date = "";
|
||||
}
|
||||
/// <summary>
|
||||
/// File MD5 hash
|
||||
/// </summary>
|
||||
public string MD5
|
||||
{
|
||||
get { return _md5.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_md5); }
|
||||
set { _md5 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a "blank" Rom object
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="machineName"></param>
|
||||
/// <param name="omitFromScan"></param>
|
||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||
public Rom(string name, string machineName, Hash omitFromScan = Hash.DeepHashes)
|
||||
{
|
||||
_name = name;
|
||||
_itemType = ItemType.Rom;
|
||||
_size = -1;
|
||||
if ((omitFromScan & Hash.CRC) == 0)
|
||||
{
|
||||
_crc = null;
|
||||
}
|
||||
if ((omitFromScan & Hash.MD5) == 0)
|
||||
{
|
||||
_md5 = null;
|
||||
}
|
||||
if ((omitFromScan & Hash.SHA1) == 0)
|
||||
{
|
||||
_sha1 = null;
|
||||
}
|
||||
if ((omitFromScan & Hash.SHA256) == 0)
|
||||
{
|
||||
_sha256 = null;
|
||||
}
|
||||
if ((omitFromScan & Hash.SHA384) == 0)
|
||||
{
|
||||
_sha384 = null;
|
||||
}
|
||||
if ((omitFromScan & Hash.SHA512) == 0)
|
||||
{
|
||||
_sha512 = null;
|
||||
}
|
||||
_itemStatus = ItemStatus.None;
|
||||
/// <summary>
|
||||
/// File SHA-1 hash
|
||||
/// </summary>
|
||||
public string SHA1
|
||||
{
|
||||
get { return _sha1.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha1); }
|
||||
set { _sha1 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
_machine = new Machine
|
||||
{
|
||||
Name = machineName,
|
||||
Description = machineName,
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// File SHA-256 hash
|
||||
/// </summary>
|
||||
public string SHA256
|
||||
{
|
||||
get { return _sha256.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha256); }
|
||||
set { _sha256 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a Rom object from a BaseFile
|
||||
/// </summary>
|
||||
/// <param name="baseFile"></param>
|
||||
public Rom(BaseFile baseFile)
|
||||
{
|
||||
_name = baseFile.Filename;
|
||||
_size = baseFile.Size ?? -1;
|
||||
_crc = baseFile.CRC;
|
||||
_md5 = baseFile.MD5;
|
||||
_sha1 = baseFile.SHA1;
|
||||
_sha256 = baseFile.SHA256;
|
||||
_sha384 = baseFile.SHA384;
|
||||
_sha512 = baseFile.SHA512;
|
||||
/// <summary>
|
||||
/// File SHA-384 hash
|
||||
/// </summary>
|
||||
public string SHA384
|
||||
{
|
||||
get { return _sha384.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha384); }
|
||||
set { _sha384 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
_itemType = ItemType.Rom;
|
||||
_dupeType = 0x00;
|
||||
_itemStatus = ItemStatus.None;
|
||||
_date = baseFile.Date;
|
||||
}
|
||||
/// <summary>
|
||||
/// File SHA-512 hash
|
||||
/// </summary>
|
||||
public string SHA512
|
||||
{
|
||||
get { return _sha512.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha512); }
|
||||
set { _sha512 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Rom name to merge from parent
|
||||
/// </summary>
|
||||
public string MergeTag { get; set; }
|
||||
|
||||
#region Cloning Methods
|
||||
/// <summary>
|
||||
/// Rom region
|
||||
/// </summary>
|
||||
public string Region { get; set; }
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new Rom()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
/// <summary>
|
||||
/// Data offset within rom
|
||||
/// </summary>
|
||||
public string Offset { get; set; }
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
/// <summary>
|
||||
/// File created date
|
||||
/// </summary>
|
||||
public string Date { get; set; }
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
/// <summary>
|
||||
/// Rom dump status
|
||||
/// </summary>
|
||||
public ItemStatus ItemStatus { get; set; }
|
||||
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
/// <summary>
|
||||
/// Determine if the rom is optional in the set
|
||||
/// </summary>
|
||||
public bool? Optional { get; set; }
|
||||
|
||||
Size = this.Size,
|
||||
_crc = this._crc,
|
||||
_md5 = this._md5,
|
||||
_sha1 = this._sha1,
|
||||
_sha256 = this._sha256,
|
||||
_sha384 = this._sha384,
|
||||
_sha512 = this._sha512,
|
||||
ItemStatus = this.ItemStatus,
|
||||
Date = this.Date,
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#region Constructors
|
||||
|
||||
#region Comparision Methods
|
||||
/// <summary>
|
||||
/// Create a default, empty Rom object
|
||||
/// </summary>
|
||||
public Rom()
|
||||
{
|
||||
this.Name = "";
|
||||
this.ItemType = ItemType.Rom;
|
||||
this.DupeType = 0x00;
|
||||
this.ItemStatus = ItemStatus.None;
|
||||
this.Date = "";
|
||||
}
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
bool dupefound = false;
|
||||
/// <summary>
|
||||
/// Create a "blank" Rom object
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="machineName"></param>
|
||||
/// <param name="omitFromScan"></param>
|
||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||
public Rom(string name, string machineName, Hash omitFromScan = Hash.DeepHashes)
|
||||
{
|
||||
this.Name = name;
|
||||
this.ItemType = ItemType.Rom;
|
||||
this.Size = -1;
|
||||
if ((omitFromScan & Hash.CRC) == 0)
|
||||
{
|
||||
_crc = null;
|
||||
}
|
||||
if ((omitFromScan & Hash.MD5) == 0)
|
||||
{
|
||||
_md5 = null;
|
||||
}
|
||||
if ((omitFromScan & Hash.SHA1) == 0)
|
||||
{
|
||||
_sha1 = null;
|
||||
}
|
||||
if ((omitFromScan & Hash.SHA256) == 0)
|
||||
{
|
||||
_sha256 = null;
|
||||
}
|
||||
if ((omitFromScan & Hash.SHA384) == 0)
|
||||
{
|
||||
_sha384 = null;
|
||||
}
|
||||
if ((omitFromScan & Hash.SHA512) == 0)
|
||||
{
|
||||
_sha512 = null;
|
||||
}
|
||||
this.ItemStatus = ItemStatus.None;
|
||||
|
||||
// If we don't have a rom, return false
|
||||
if (_itemType != other.ItemType)
|
||||
{
|
||||
return dupefound;
|
||||
}
|
||||
_machine = new Machine
|
||||
{
|
||||
Name = machineName,
|
||||
Description = machineName,
|
||||
};
|
||||
}
|
||||
|
||||
// Otherwise, treat it as a rom
|
||||
Rom newOther = (Rom)other;
|
||||
/// <summary>
|
||||
/// Create a Rom object from a BaseFile
|
||||
/// </summary>
|
||||
/// <param name="baseFile"></param>
|
||||
public Rom(BaseFile baseFile)
|
||||
{
|
||||
this.Name = baseFile.Filename;
|
||||
this.Size = baseFile.Size ?? -1;
|
||||
_crc = baseFile.CRC;
|
||||
_md5 = baseFile.MD5;
|
||||
_sha1 = baseFile.SHA1;
|
||||
_sha256 = baseFile.SHA256;
|
||||
_sha384 = baseFile.SHA384;
|
||||
_sha512 = baseFile.SHA512;
|
||||
|
||||
// If all hashes are empty but they're both nodump and the names match, then they're dupes
|
||||
if ((this._itemStatus == ItemStatus.Nodump && newOther._itemStatus == ItemStatus.Nodump)
|
||||
&& (this._name == newOther._name)
|
||||
&& (this._crc.IsNullOrWhiteSpace() && newOther._crc.IsNullOrWhiteSpace())
|
||||
&& (this._md5.IsNullOrWhiteSpace() && newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() && newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() && newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() && newOther._sha384.IsNullOrWhiteSpace())
|
||||
&& (this._sha512.IsNullOrWhiteSpace() && newOther._sha512.IsNullOrWhiteSpace()))
|
||||
{
|
||||
dupefound = true;
|
||||
}
|
||||
this.ItemType = ItemType.Rom;
|
||||
this.DupeType = 0x00;
|
||||
this.ItemStatus = ItemStatus.None;
|
||||
this.Date = baseFile.Date;
|
||||
}
|
||||
|
||||
// If we can determine that the roms have no non-empty hashes in common, we return false
|
||||
else if ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace())
|
||||
&& (this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace())
|
||||
&& (this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()))
|
||||
{
|
||||
dupefound = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
// Otherwise if we get a partial match
|
||||
else if ((this.Size == newOther.Size)
|
||||
&& ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._crc, newOther._crc))
|
||||
&& ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
&& ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
&& ((this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512)))
|
||||
{
|
||||
dupefound = true;
|
||||
}
|
||||
#region Cloning Methods
|
||||
|
||||
return dupefound;
|
||||
}
|
||||
public override object Clone()
|
||||
{
|
||||
return new Rom()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
#endregion
|
||||
}
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
|
||||
Size = this.Size,
|
||||
_crc = this._crc,
|
||||
_md5 = this._md5,
|
||||
_sha1 = this._sha1,
|
||||
_sha256 = this._sha256,
|
||||
_sha384 = this._sha384,
|
||||
_sha512 = this._sha512,
|
||||
ItemStatus = this.ItemStatus,
|
||||
Date = this.Date,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
bool dupefound = false;
|
||||
|
||||
// If we don't have a rom, return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
{
|
||||
return dupefound;
|
||||
}
|
||||
|
||||
// Otherwise, treat it as a rom
|
||||
Rom newOther = (Rom)other;
|
||||
|
||||
// If all hashes are empty but they're both nodump and the names match, then they're dupes
|
||||
if ((this.ItemStatus == ItemStatus.Nodump && newOther.ItemStatus == ItemStatus.Nodump)
|
||||
&& (this.Name == newOther.Name)
|
||||
&& (this._crc.IsNullOrWhiteSpace() && newOther._crc.IsNullOrWhiteSpace())
|
||||
&& (this._md5.IsNullOrWhiteSpace() && newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() && newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() && newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() && newOther._sha384.IsNullOrWhiteSpace())
|
||||
&& (this._sha512.IsNullOrWhiteSpace() && newOther._sha512.IsNullOrWhiteSpace()))
|
||||
{
|
||||
dupefound = true;
|
||||
}
|
||||
|
||||
// If we can determine that the roms have no non-empty hashes in common, we return false
|
||||
else if ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace())
|
||||
&& (this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace())
|
||||
&& (this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()))
|
||||
{
|
||||
dupefound = false;
|
||||
}
|
||||
|
||||
// Otherwise if we get a partial match
|
||||
else if ((this.Size == newOther.Size)
|
||||
&& ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._crc, newOther._crc))
|
||||
&& ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
&& ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
&& ((this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512)))
|
||||
{
|
||||
dupefound = true;
|
||||
}
|
||||
|
||||
return dupefound;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,84 +2,84 @@
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a (usually WAV-formatted) sample to be included for use in the set
|
||||
/// </summary>
|
||||
public class Sample : DatItem
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Represents a (usually WAV-formatted) sample to be included for use in the set
|
||||
/// </summary>
|
||||
public class Sample : DatItem
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty Sample object
|
||||
/// </summary>
|
||||
public Sample()
|
||||
{
|
||||
_name = "";
|
||||
_itemType = ItemType.Sample;
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a default, empty Sample object
|
||||
/// </summary>
|
||||
public Sample()
|
||||
{
|
||||
this.Name = "";
|
||||
this.ItemType = ItemType.Sample;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
#region Cloning Methods
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new Sample()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
public override object Clone()
|
||||
{
|
||||
return new Sample()
|
||||
{
|
||||
Name = this.Name,
|
||||
ItemType = this.ItemType,
|
||||
DupeType = this.DupeType,
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
MachineName = this.MachineName,
|
||||
Comment = this.Comment,
|
||||
MachineDescription = this.MachineDescription,
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
Board = this.Board,
|
||||
RebuildTo = this.RebuildTo,
|
||||
Devices = this.Devices,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
};
|
||||
}
|
||||
SystemID = this.SystemID,
|
||||
System = this.System,
|
||||
SourceID = this.SourceID,
|
||||
Source = this.Source,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
#region Comparision Methods
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a sample, return false
|
||||
if (_itemType != other.ItemType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a sample, return false
|
||||
if (this.ItemType != other.ItemType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, treat it as a sample
|
||||
Sample newOther = (Sample)other;
|
||||
// Otherwise, treat it as a sample
|
||||
Sample newOther = (Sample)other;
|
||||
|
||||
// If the archive information matches
|
||||
return (_name == newOther.Name);
|
||||
}
|
||||
// If the archive information matches
|
||||
return (this.Name == newOther.Name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user