Use ByteArrays for hashes (#2)
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [SabreTools, GZipArchive] Refix some issues from rebase
* # This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 4 commits.
# This is the 1st commit message:
[Disk, Rom] Use byte arrays for hashes to save memory
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #3:
[ArchiveTools, FileTools] Use the Style method more
# This is the commit message #4:
[SabreTools, GZipArchive] Refix some issues from rebase
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
* [Disk, Rom, Style] Add null or empty check to fix equality check
* [Disk, Rom] Remove unused references
* [Style] Add and implement BinaryReader extensions
2017-11-02 15:35:15 -07:00
|
|
|
|
using System.Linq;
|
2016-10-24 13:51:39 -07:00
|
|
|
|
|
2017-05-04 02:41:11 -07:00
|
|
|
|
using SabreTools.Library.Data;
|
2018-02-15 23:38:55 -08:00
|
|
|
|
using SabreTools.Library.FileTypes;
|
Use ByteArrays for hashes (#2)
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [SabreTools, GZipArchive] Refix some issues from rebase
* # This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 4 commits.
# This is the 1st commit message:
[Disk, Rom] Use byte arrays for hashes to save memory
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #3:
[ArchiveTools, FileTools] Use the Style method more
# This is the commit message #4:
[SabreTools, GZipArchive] Refix some issues from rebase
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
* [Disk, Rom, Style] Add null or empty check to fix equality check
* [Disk, Rom] Remove unused references
* [Style] Add and implement BinaryReader extensions
2017-11-02 15:35:15 -07:00
|
|
|
|
using SabreTools.Library.Tools;
|
2016-09-19 20:36:12 -07:00
|
|
|
|
|
2017-11-02 15:44:15 -07:00
|
|
|
|
namespace SabreTools.Library.DatItems
|
2016-09-19 18:04:24 -07:00
|
|
|
|
{
|
2017-10-09 12:58:46 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents a generic file within a set
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class Rom : DatItem
|
2016-09-19 18:04:24 -07:00
|
|
|
|
{
|
|
|
|
|
|
#region Private instance variables
|
|
|
|
|
|
|
|
|
|
|
|
// Rom information
|
2018-01-13 22:42:42 -08:00
|
|
|
|
private string _bios;
|
2017-10-09 12:58:46 -07:00
|
|
|
|
private long _size;
|
Use ByteArrays for hashes (#2)
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [SabreTools, GZipArchive] Refix some issues from rebase
* # This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 4 commits.
# This is the 1st commit message:
[Disk, Rom] Use byte arrays for hashes to save memory
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #3:
[ArchiveTools, FileTools] Use the Style method more
# This is the commit message #4:
[SabreTools, GZipArchive] Refix some issues from rebase
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
* [Disk, Rom, Style] Add null or empty check to fix equality check
* [Disk, Rom] Remove unused references
* [Style] Add and implement BinaryReader extensions
2017-11-02 15:35:15 -07:00
|
|
|
|
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
|
2018-01-13 22:42:42 -08:00
|
|
|
|
private string _merge;
|
|
|
|
|
|
private string _region;
|
|
|
|
|
|
private string _offset;
|
2016-09-19 18:04:24 -07:00
|
|
|
|
private string _date;
|
2017-10-09 12:58:46 -07:00
|
|
|
|
private ItemStatus _itemStatus;
|
2018-01-13 22:42:42 -08:00
|
|
|
|
private bool? _optional;
|
2016-09-19 18:04:24 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Publicly facing variables
|
|
|
|
|
|
|
|
|
|
|
|
// Rom information
|
2018-01-13 22:42:42 -08:00
|
|
|
|
public string Bios
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _bios; }
|
|
|
|
|
|
set { _bios = value; }
|
|
|
|
|
|
}
|
2016-09-19 20:36:12 -07:00
|
|
|
|
public long Size
|
2016-09-19 18:04:24 -07:00
|
|
|
|
{
|
2016-09-19 20:36:12 -07:00
|
|
|
|
get { return _size; }
|
|
|
|
|
|
set { _size = value; }
|
2016-09-19 18:04:24 -07:00
|
|
|
|
}
|
2016-09-19 20:36:12 -07:00
|
|
|
|
public string CRC
|
2016-09-19 18:04:24 -07:00
|
|
|
|
{
|
2017-11-08 13:15:44 -08:00
|
|
|
|
get { return _crc.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_crc); }
|
2018-02-15 18:47:11 -08:00
|
|
|
|
set { _crc = (value == "null" ? Constants.CRCZeroBytes : Utilities.StringToByteArray(value)); }
|
2016-09-19 18:04:24 -07:00
|
|
|
|
}
|
2017-10-09 12:58:46 -07:00
|
|
|
|
public string MD5
|
|
|
|
|
|
{
|
2017-11-08 13:15:44 -08:00
|
|
|
|
get { return _md5.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_md5); }
|
2018-02-15 18:47:11 -08:00
|
|
|
|
set { _md5 = (value == "null" ? Constants.MD5ZeroBytes : Utilities.StringToByteArray(value)); }
|
2017-10-09 12:58:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
public string SHA1
|
|
|
|
|
|
{
|
2017-11-08 13:15:44 -08:00
|
|
|
|
get { return _sha1.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha1); }
|
2018-02-15 18:47:11 -08:00
|
|
|
|
set { _sha1 = (value == "null" ? Constants.SHA1ZeroBytes : Utilities.StringToByteArray(value)); }
|
2017-10-09 12:58:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
public string SHA256
|
|
|
|
|
|
{
|
2017-11-08 13:15:44 -08:00
|
|
|
|
get { return _sha256.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha256); }
|
2018-02-15 18:47:11 -08:00
|
|
|
|
set { _sha256 = (value == "null" ? Constants.SHA256ZeroBytes : Utilities.StringToByteArray(value)); }
|
2017-10-09 12:58:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
public string SHA384
|
|
|
|
|
|
{
|
2017-11-08 13:15:44 -08:00
|
|
|
|
get { return _sha384.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha384); }
|
2018-02-15 18:47:11 -08:00
|
|
|
|
set { _sha384 = (value == "null" ? Constants.SHA384ZeroBytes : Utilities.StringToByteArray(value)); }
|
2017-10-09 12:58:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
public string SHA512
|
|
|
|
|
|
{
|
2017-11-08 13:15:44 -08:00
|
|
|
|
get { return _sha512.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha512); }
|
2018-02-15 18:47:11 -08:00
|
|
|
|
set { _sha512 = (value == "null" ? Constants.SHA512ZeroBytes : Utilities.StringToByteArray(value)); }
|
2017-10-09 12:58:46 -07:00
|
|
|
|
}
|
2018-01-13 22:42:42 -08:00
|
|
|
|
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; }
|
|
|
|
|
|
}
|
2016-09-19 18:04:24 -07:00
|
|
|
|
public string Date
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _date; }
|
|
|
|
|
|
set { _date = value; }
|
|
|
|
|
|
}
|
2017-10-09 12:58:46 -07:00
|
|
|
|
public ItemStatus ItemStatus
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _itemStatus; }
|
|
|
|
|
|
set { _itemStatus = value; }
|
2018-01-13 22:42:42 -08:00
|
|
|
|
}
|
|
|
|
|
|
public bool? Optional
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _optional; }
|
|
|
|
|
|
set { _optional = value; }
|
2017-10-09 12:58:46 -07:00
|
|
|
|
}
|
2016-09-19 18:04:24 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty Rom object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Rom()
|
|
|
|
|
|
{
|
2017-01-27 16:53:29 -08:00
|
|
|
|
_name = "";
|
2016-09-19 18:04:24 -07:00
|
|
|
|
_itemType = ItemType.Rom;
|
2016-10-05 20:33:02 -07:00
|
|
|
|
_dupeType = 0x00;
|
2016-09-21 15:45:40 -07:00
|
|
|
|
_itemStatus = ItemStatus.None;
|
2017-01-27 16:53:29 -08:00
|
|
|
|
_date = "";
|
2016-09-19 18:04:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a "blank" Rom object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name"></param>
|
|
|
|
|
|
/// <param name="machineName"></param>
|
2017-03-14 15:18:07 -07:00
|
|
|
|
/// <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)
|
2016-09-19 18:04:24 -07:00
|
|
|
|
{
|
2016-10-24 13:38:20 -07:00
|
|
|
|
_name = name;
|
|
|
|
|
|
_itemType = ItemType.Rom;
|
|
|
|
|
|
_size = -1;
|
2017-03-14 15:18:07 -07:00
|
|
|
|
if ((omitFromScan & Hash.CRC) == 0)
|
|
|
|
|
|
{
|
Use ByteArrays for hashes (#2)
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [SabreTools, GZipArchive] Refix some issues from rebase
* # This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 4 commits.
# This is the 1st commit message:
[Disk, Rom] Use byte arrays for hashes to save memory
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #3:
[ArchiveTools, FileTools] Use the Style method more
# This is the commit message #4:
[SabreTools, GZipArchive] Refix some issues from rebase
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
* [Disk, Rom, Style] Add null or empty check to fix equality check
* [Disk, Rom] Remove unused references
* [Style] Add and implement BinaryReader extensions
2017-11-02 15:35:15 -07:00
|
|
|
|
_crc = null;
|
2017-03-14 15:18:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
if ((omitFromScan & Hash.MD5) == 0)
|
|
|
|
|
|
{
|
Use ByteArrays for hashes (#2)
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [SabreTools, GZipArchive] Refix some issues from rebase
* # This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 4 commits.
# This is the 1st commit message:
[Disk, Rom] Use byte arrays for hashes to save memory
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #3:
[ArchiveTools, FileTools] Use the Style method more
# This is the commit message #4:
[SabreTools, GZipArchive] Refix some issues from rebase
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
* [Disk, Rom, Style] Add null or empty check to fix equality check
* [Disk, Rom] Remove unused references
* [Style] Add and implement BinaryReader extensions
2017-11-02 15:35:15 -07:00
|
|
|
|
_md5 = null;
|
2017-03-14 15:18:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
if ((omitFromScan & Hash.SHA1) == 0)
|
|
|
|
|
|
{
|
Use ByteArrays for hashes (#2)
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [SabreTools, GZipArchive] Refix some issues from rebase
* # This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 4 commits.
# This is the 1st commit message:
[Disk, Rom] Use byte arrays for hashes to save memory
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #3:
[ArchiveTools, FileTools] Use the Style method more
# This is the commit message #4:
[SabreTools, GZipArchive] Refix some issues from rebase
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
* [Disk, Rom, Style] Add null or empty check to fix equality check
* [Disk, Rom] Remove unused references
* [Style] Add and implement BinaryReader extensions
2017-11-02 15:35:15 -07:00
|
|
|
|
_sha1 = null;
|
2017-03-14 15:18:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
if ((omitFromScan & Hash.SHA256) == 0)
|
|
|
|
|
|
{
|
Use ByteArrays for hashes (#2)
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [SabreTools, GZipArchive] Refix some issues from rebase
* # This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 4 commits.
# This is the 1st commit message:
[Disk, Rom] Use byte arrays for hashes to save memory
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #3:
[ArchiveTools, FileTools] Use the Style method more
# This is the commit message #4:
[SabreTools, GZipArchive] Refix some issues from rebase
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
* [Disk, Rom, Style] Add null or empty check to fix equality check
* [Disk, Rom] Remove unused references
* [Style] Add and implement BinaryReader extensions
2017-11-02 15:35:15 -07:00
|
|
|
|
_sha256 = null;
|
2017-03-14 15:18:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
if ((omitFromScan & Hash.SHA384) == 0)
|
|
|
|
|
|
{
|
Use ByteArrays for hashes (#2)
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [SabreTools, GZipArchive] Refix some issues from rebase
* # This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 4 commits.
# This is the 1st commit message:
[Disk, Rom] Use byte arrays for hashes to save memory
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #3:
[ArchiveTools, FileTools] Use the Style method more
# This is the commit message #4:
[SabreTools, GZipArchive] Refix some issues from rebase
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
* [Disk, Rom, Style] Add null or empty check to fix equality check
* [Disk, Rom] Remove unused references
* [Style] Add and implement BinaryReader extensions
2017-11-02 15:35:15 -07:00
|
|
|
|
_sha384 = null;
|
2017-03-14 15:18:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
if ((omitFromScan & Hash.SHA512) == 0)
|
|
|
|
|
|
{
|
Use ByteArrays for hashes (#2)
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [SabreTools, GZipArchive] Refix some issues from rebase
* # This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 4 commits.
# This is the 1st commit message:
[Disk, Rom] Use byte arrays for hashes to save memory
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #3:
[ArchiveTools, FileTools] Use the Style method more
# This is the commit message #4:
[SabreTools, GZipArchive] Refix some issues from rebase
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
* [Disk, Rom, Style] Add null or empty check to fix equality check
* [Disk, Rom] Remove unused references
* [Style] Add and implement BinaryReader extensions
2017-11-02 15:35:15 -07:00
|
|
|
|
_sha512 = null;
|
2017-03-14 15:18:07 -07:00
|
|
|
|
}
|
2016-10-24 13:38:20 -07:00
|
|
|
|
_itemStatus = ItemStatus.None;
|
|
|
|
|
|
|
2016-10-24 12:58:57 -07:00
|
|
|
|
_machine = new Machine
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = machineName,
|
|
|
|
|
|
Description = machineName,
|
|
|
|
|
|
};
|
2016-09-19 18:04:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-15 23:38:55 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a Rom object from a BaseFile
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="baseFile"></param>
|
|
|
|
|
|
public Rom(BaseFile baseFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
_name = baseFile.Filename;
|
2018-02-23 11:06:01 -08:00
|
|
|
|
_size = baseFile.Size ?? -1;
|
2018-02-15 23:38:55 -08:00
|
|
|
|
_crc = baseFile.CRC;
|
|
|
|
|
|
_md5 = baseFile.MD5;
|
|
|
|
|
|
_sha1 = baseFile.SHA1;
|
|
|
|
|
|
_sha256 = baseFile.SHA256;
|
|
|
|
|
|
_sha384 = baseFile.SHA384;
|
|
|
|
|
|
_sha512 = baseFile.SHA512;
|
2018-02-23 11:06:01 -08:00
|
|
|
|
|
|
|
|
|
|
_itemType = ItemType.Rom;
|
|
|
|
|
|
_dupeType = 0x00;
|
|
|
|
|
|
_itemStatus = ItemStatus.None;
|
2018-03-04 21:40:10 -08:00
|
|
|
|
_date = baseFile.Date;
|
2018-02-15 23:38:55 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-19 18:04:24 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2017-01-09 14:37:41 -08:00
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
2017-10-09 13:37:15 -07:00
|
|
|
|
public override object Clone()
|
2017-01-09 14:37:41 -08:00
|
|
|
|
{
|
2017-10-09 13:46:28 -07:00
|
|
|
|
return new Rom()
|
2017-01-09 14:37:41 -08:00
|
|
|
|
{
|
|
|
|
|
|
Name = this.Name,
|
|
|
|
|
|
Type = this.Type,
|
|
|
|
|
|
Dupe = this.Dupe,
|
|
|
|
|
|
|
|
|
|
|
|
Supported = this.Supported,
|
|
|
|
|
|
Publisher = this.Publisher,
|
|
|
|
|
|
Infos = this.Infos,
|
|
|
|
|
|
PartName = this.PartName,
|
|
|
|
|
|
PartInterface = this.PartInterface,
|
|
|
|
|
|
Features = this.Features,
|
|
|
|
|
|
AreaName = this.AreaName,
|
|
|
|
|
|
AreaSize = this.AreaSize,
|
|
|
|
|
|
|
2017-10-09 13:46:28 -07:00
|
|
|
|
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,
|
|
|
|
|
|
|
2017-01-09 14:37:41 -08:00
|
|
|
|
SystemID = this.SystemID,
|
|
|
|
|
|
System = this.System,
|
|
|
|
|
|
SourceID = this.SourceID,
|
|
|
|
|
|
Source = this.Source,
|
|
|
|
|
|
|
|
|
|
|
|
Size = this.Size,
|
Use ByteArrays for hashes (#2)
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [Disk, Rom] Use byte arrays for hashes to save memory
* [FileTools] Use ByteArrayToString in CHD info
* [ArchiveTools, FileTools] Use the Style method more
* [SabreTools, GZipArchive] Refix some issues from rebase
* # This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 2 commits.
# This is the 1st commit message:
# This is a combination of 4 commits.
# This is the 1st commit message:
[Disk, Rom] Use byte arrays for hashes to save memory
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #3:
[ArchiveTools, FileTools] Use the Style method more
# This is the commit message #4:
[SabreTools, GZipArchive] Refix some issues from rebase
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
# This is the commit message #2:
[FileTools] Use ByteArrayToString in CHD info
* [Disk, Rom, Style] Add null or empty check to fix equality check
* [Disk, Rom] Remove unused references
* [Style] Add and implement BinaryReader extensions
2017-11-02 15:35:15 -07:00
|
|
|
|
_crc = this._crc,
|
|
|
|
|
|
_md5 = this._md5,
|
|
|
|
|
|
_sha1 = this._sha1,
|
|
|
|
|
|
_sha256 = this._sha256,
|
|
|
|
|
|
_sha384 = this._sha384,
|
|
|
|
|
|
_sha512 = this._sha512,
|
2017-10-09 13:46:28 -07:00
|
|
|
|
ItemStatus = this.ItemStatus,
|
2017-01-09 14:37:41 -08:00
|
|
|
|
Date = this.Date,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2016-09-19 18:04:24 -07:00
|
|
|
|
#region Comparision Methods
|
|
|
|
|
|
|
|
|
|
|
|
public override bool Equals(DatItem other)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool dupefound = false;
|
|
|
|
|
|
|
|
|
|
|
|
// If we don't have a rom, return false
|
2016-09-19 22:28:17 -07:00
|
|
|
|
if (_itemType != other.Type)
|
2016-09-19 18:04:24 -07:00
|
|
|
|
{
|
|
|
|
|
|
return dupefound;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, treat it as a rom
|
|
|
|
|
|
Rom newOther = (Rom)other;
|
|
|
|
|
|
|
2017-11-09 00:20:47 -08:00
|
|
|
|
// 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()))
|
2016-09-19 18:04:24 -07:00
|
|
|
|
{
|
2017-11-09 00:20:47 -08:00
|
|
|
|
dupefound = true;
|
2016-09-19 18:04:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-07-17 14:19:20 -07:00
|
|
|
|
// If we can determine that the roms have no non-empty hashes in common, we return false
|
2017-11-09 00:20:47 -08:00
|
|
|
|
else if ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace())
|
2017-11-08 13:15:44 -08:00
|
|
|
|
&& (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()))
|
2017-07-17 16:15:02 -07:00
|
|
|
|
{
|
2017-07-17 14:19:20 -07:00
|
|
|
|
dupefound = false;
|
|
|
|
|
|
}
|
2017-11-09 00:20:47 -08:00
|
|
|
|
|
|
|
|
|
|
// Otherwise if we get a partial match
|
2017-07-17 14:19:20 -07:00
|
|
|
|
else if ((this.Size == newOther.Size)
|
2017-11-08 13:15:44 -08:00
|
|
|
|
&& ((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)))
|
2016-09-19 20:36:12 -07:00
|
|
|
|
{
|
|
|
|
|
|
dupefound = true;
|
|
|
|
|
|
}
|
2016-09-19 18:04:24 -07:00
|
|
|
|
|
|
|
|
|
|
return dupefound;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|