mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] Remove Hash struct
This is a bit controversial, even for me, but for the time being, we need to tie very specific information to each type of item. That means that a Rom and a Disk, though they both have hashes, they have different hashes. I'm going to see how this plays out for the time being.
This commit is contained in:
@@ -341,15 +341,15 @@ namespace SabreTools
|
|||||||
Rom dat = FileTools.GetSingleFileInfo(file);
|
Rom dat = FileTools.GetSingleFileInfo(file);
|
||||||
|
|
||||||
// If the Dat isn't in the database and isn't already accounted for in the DatRoot, add it
|
// If the Dat isn't in the database and isn't already accounted for in the DatRoot, add it
|
||||||
if (!databaseDats.Contains(dat.HashData.SHA1) && !toscan.ContainsKey(dat.HashData.SHA1))
|
if (!databaseDats.Contains(dat.SHA1) && !toscan.ContainsKey(dat.SHA1))
|
||||||
{
|
{
|
||||||
toscan.Add(dat.HashData.SHA1, Path.GetFullPath(file));
|
toscan.Add(dat.SHA1, Path.GetFullPath(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the Dat is in the database already, remove it to find stragglers
|
// If the Dat is in the database already, remove it to find stragglers
|
||||||
else if (databaseDats.Contains(dat.HashData.SHA1))
|
else if (databaseDats.Contains(dat.SHA1))
|
||||||
{
|
{
|
||||||
databaseDats.Remove(dat.HashData.SHA1);
|
databaseDats.Remove(dat.SHA1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,10 +368,10 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
foreach (Rom rom in tempdat.Files[romkey])
|
foreach (Rom rom in tempdat.Files[romkey])
|
||||||
{
|
{
|
||||||
query = "SELECT id FROM data WHERE key=\"size\" AND value=\"" + rom.HashData.Size + "\" AND ("
|
query = "SELECT id FROM data WHERE key=\"size\" AND value=\"" + rom.Size + "\" AND ("
|
||||||
+ "(key=\"crc\" AND (value=\"" + rom.HashData.CRC + "\" OR value=\"null\"))"
|
+ "(key=\"crc\" AND (value=\"" + rom.CRC + "\" OR value=\"null\"))"
|
||||||
+ "AND (key=\"md5\" AND value=\"" + rom.HashData.MD5 + "\" OR value=\"null\"))"
|
+ "AND (key=\"md5\" AND value=\"" + rom.MD5 + "\" OR value=\"null\"))"
|
||||||
+ "AND (key=\"sha1\" AND value=\"" + rom.HashData.SHA1 + "\" OR value=\"null\")))";
|
+ "AND (key=\"sha1\" AND value=\"" + rom.SHA1 + "\" OR value=\"null\")))";
|
||||||
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
||||||
{
|
{
|
||||||
using (SqliteDataReader sldr = slc.ExecuteReader())
|
using (SqliteDataReader sldr = slc.ExecuteReader())
|
||||||
@@ -392,7 +392,7 @@ namespace SabreTools
|
|||||||
// If it doesn't exist, add the hash and the dat hash for a new id
|
// If it doesn't exist, add the hash and the dat hash for a new id
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string squery = "INSERT INTO data (key, value) VALUES (\"size\", \"" + rom.HashData.Size + "\")";
|
string squery = "INSERT INTO data (key, value) VALUES (\"size\", \"" + rom.Size + "\")";
|
||||||
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
||||||
{
|
{
|
||||||
sslc.ExecuteNonQuery();
|
sslc.ExecuteNonQuery();
|
||||||
@@ -406,9 +406,9 @@ namespace SabreTools
|
|||||||
id = (long)sslc.ExecuteScalar();
|
id = (long)sslc.ExecuteScalar();
|
||||||
}
|
}
|
||||||
|
|
||||||
squery = "INSERT INTO data (id, key, value) VALUES (\"" + id + "\", \"crc\", \"" + rom.HashData.CRC + "\"),"
|
squery = "INSERT INTO data (id, key, value) VALUES (\"" + id + "\", \"crc\", \"" + rom.CRC + "\"),"
|
||||||
+ " (\"" + id + "\", \"md5\", \"" + rom.HashData.MD5 + "\"),"
|
+ " (\"" + id + "\", \"md5\", \"" + rom.MD5 + "\"),"
|
||||||
+ " (\"" + id + "\", \"sha1\", \"" + rom.HashData.SHA1 + "\"),"
|
+ " (\"" + id + "\", \"sha1\", \"" + rom.SHA1 + "\"),"
|
||||||
+ " (\"" + id + "\", \"dat\", \"" + key + "\"),"
|
+ " (\"" + id + "\", \"dat\", \"" + key + "\"),"
|
||||||
+ " (\"" + id + "\", \"exists\", \"false\")";
|
+ " (\"" + id + "\", \"exists\", \"false\")";
|
||||||
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
using (SqliteCommand sslc = new SqliteCommand(squery, dbc))
|
||||||
@@ -451,7 +451,7 @@ namespace SabreTools
|
|||||||
if (datRootDats.Contains(input.ToLowerInvariant()))
|
if (datRootDats.Contains(input.ToLowerInvariant()))
|
||||||
{
|
{
|
||||||
string fullpath = Path.GetFullPath(datRootDats[datRootDats.IndexOf(input.ToLowerInvariant())]);
|
string fullpath = Path.GetFullPath(datRootDats[datRootDats.IndexOf(input.ToLowerInvariant())]);
|
||||||
string sha1 = FileTools.GetSingleFileInfo(fullpath).HashData.SHA1;
|
string sha1 = FileTools.GetSingleFileInfo(fullpath).SHA1;
|
||||||
foundDats.Add(sha1, fullpath);
|
foundDats.Add(sha1, fullpath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3,48 +3,6 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace SabreTools.Helper
|
namespace SabreTools.Helper
|
||||||
{
|
{
|
||||||
#region Dat-to-Hash structs
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Intermediate struct for holding and processing hash data
|
|
||||||
/// </summary>
|
|
||||||
public struct Hash : IEquatable<Hash>
|
|
||||||
{
|
|
||||||
public long Size;
|
|
||||||
public string CRC;
|
|
||||||
public string MD5;
|
|
||||||
public string SHA1;
|
|
||||||
|
|
||||||
public bool Equals(Hash other)
|
|
||||||
{
|
|
||||||
return this.Equals(other, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(Hash other, bool IsDisk)
|
|
||||||
{
|
|
||||||
bool equals = false;
|
|
||||||
|
|
||||||
if (IsDisk &&
|
|
||||||
((String.IsNullOrEmpty(this.MD5) || String.IsNullOrEmpty(other.MD5)) || this.MD5 == other.MD5) &&
|
|
||||||
((String.IsNullOrEmpty(this.SHA1) || String.IsNullOrEmpty(other.SHA1)) || this.SHA1 == other.SHA1))
|
|
||||||
{
|
|
||||||
equals = true;
|
|
||||||
}
|
|
||||||
else if (!IsDisk &&
|
|
||||||
(this.Size == other.Size) &&
|
|
||||||
((String.IsNullOrEmpty(this.CRC) || String.IsNullOrEmpty(other.CRC)) || this.CRC == other.CRC) &&
|
|
||||||
((String.IsNullOrEmpty(this.MD5) || String.IsNullOrEmpty(other.MD5)) || this.MD5 == other.MD5) &&
|
|
||||||
((String.IsNullOrEmpty(this.SHA1) || String.IsNullOrEmpty(other.SHA1)) || this.SHA1 == other.SHA1))
|
|
||||||
{
|
|
||||||
equals = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return equals;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Skipper structs
|
#region Skipper structs
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ namespace SabreTools
|
|||||||
if (rom.Name != null)
|
if (rom.Name != null)
|
||||||
{
|
{
|
||||||
// Add the list if it doesn't exist already
|
// Add the list if it doesn't exist already
|
||||||
string key = rom.HashData.Size + "-" + rom.HashData.CRC;
|
string key = rom.Size + "-" + rom.CRC;
|
||||||
|
|
||||||
lock (_datdata.Files)
|
lock (_datdata.Files)
|
||||||
{
|
{
|
||||||
@@ -317,11 +317,11 @@ namespace SabreTools
|
|||||||
string key = "";
|
string key = "";
|
||||||
if (datItem.Type == ItemType.Rom)
|
if (datItem.Type == ItemType.Rom)
|
||||||
{
|
{
|
||||||
key = ((Rom)datItem).HashData.Size + "-" + ((Rom)datItem).HashData.CRC;
|
key = ((Rom)datItem).Size + "-" + ((Rom)datItem).CRC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = ((Disk)datItem).HashData.Size + "-" + ((Disk)datItem).HashData.MD5;
|
key = ((Disk)datItem).MD5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the list if it doesn't exist already
|
// Add the list if it doesn't exist already
|
||||||
|
|||||||
@@ -795,7 +795,6 @@ namespace SabreTools.Helper
|
|||||||
item.Year = year;
|
item.Year = year;
|
||||||
item.SystemID = sysid;
|
item.SystemID = sysid;
|
||||||
item.SourceID = srcid;
|
item.SourceID = srcid;
|
||||||
Hash tempHash = new Hash();
|
|
||||||
|
|
||||||
// If we have a sample, treat it special
|
// If we have a sample, treat it special
|
||||||
if (temptype == ItemType.Sample)
|
if (temptype == ItemType.Sample)
|
||||||
@@ -845,16 +844,41 @@ namespace SabreTools.Helper
|
|||||||
item.Name = gc[i].Replace("\"", "");
|
item.Name = gc[i].Replace("\"", "");
|
||||||
break;
|
break;
|
||||||
case "size":
|
case "size":
|
||||||
Int64.TryParse(gc[i].Replace("\"", ""), out tempHash.Size);
|
if (item.Type == ItemType.Rom)
|
||||||
|
{
|
||||||
|
long size = -1;
|
||||||
|
if (Int64.TryParse(gc[i].Replace("\"", ""), out size))
|
||||||
|
{
|
||||||
|
((Rom)item).Size = size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "crc":
|
case "crc":
|
||||||
tempHash.CRC = gc[i].Replace("\"", "").ToLowerInvariant();
|
if (item.Type == ItemType.Rom)
|
||||||
|
{
|
||||||
|
((Rom)item).CRC = gc[i].Replace("\"", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "md5":
|
case "md5":
|
||||||
tempHash.MD5 = gc[i].Replace("\"", "").ToLowerInvariant();
|
if (item.Type == ItemType.Rom)
|
||||||
|
{
|
||||||
|
((Rom)item).MD5 = gc[i].Replace("\"", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
|
else if (item.Type == ItemType.Disk)
|
||||||
|
{
|
||||||
|
((Disk)item).MD5 = gc[i].Replace("\"", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "sha1":
|
case "sha1":
|
||||||
tempHash.SHA1 = gc[i].Replace("\"", "").ToLowerInvariant();
|
if (item.Type == ItemType.Rom)
|
||||||
|
{
|
||||||
|
((Rom)item).SHA1 = gc[i].Replace("\"", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
|
else if (item.Type == ItemType.Disk)
|
||||||
|
{
|
||||||
|
((Disk)item).SHA1 = gc[i].Replace("\"", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "flags":
|
case "flags":
|
||||||
if (gc[i].Replace("\"", "").ToLowerInvariant() == "nodump")
|
if (gc[i].Replace("\"", "").ToLowerInvariant() == "nodump")
|
||||||
@@ -916,16 +940,40 @@ namespace SabreTools.Helper
|
|||||||
item.Name = val;
|
item.Name = val;
|
||||||
break;
|
break;
|
||||||
case "size":
|
case "size":
|
||||||
Int64.TryParse(val, out tempHash.Size);
|
if (item.Type == ItemType.Rom)
|
||||||
|
{
|
||||||
|
long size = -1;
|
||||||
|
if (Int64.TryParse(gc[i].Replace("\"", ""), out size))
|
||||||
|
{
|
||||||
|
((Rom)item).Size = size;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "crc":
|
case "crc":
|
||||||
tempHash.CRC = val.ToLowerInvariant();
|
if (item.Type == ItemType.Rom)
|
||||||
|
{
|
||||||
|
((Rom)item).CRC = gc[i].Replace("\"", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "md5":
|
case "md5":
|
||||||
tempHash.MD5 = val.ToLowerInvariant();
|
if (item.Type == ItemType.Rom)
|
||||||
|
{
|
||||||
|
((Rom)item).MD5 = gc[i].Replace("\"", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
|
else if (item.Type == ItemType.Disk)
|
||||||
|
{
|
||||||
|
((Disk)item).MD5 = gc[i].Replace("\"", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "sha1":
|
case "sha1":
|
||||||
tempHash.SHA1 = val.ToLowerInvariant();
|
if (item.Type == ItemType.Rom)
|
||||||
|
{
|
||||||
|
((Rom)item).SHA1 = gc[i].Replace("\"", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
|
else if (item.Type == ItemType.Disk)
|
||||||
|
{
|
||||||
|
((Disk)item).SHA1 = gc[i].Replace("\"", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "flags":
|
case "flags":
|
||||||
if (val.ToLowerInvariant() == "nodump")
|
if (val.ToLowerInvariant() == "nodump")
|
||||||
@@ -958,14 +1006,6 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
// Now process and add the rom
|
// Now process and add the rom
|
||||||
string key = "";
|
string key = "";
|
||||||
if (item.Type == ItemType.Rom)
|
|
||||||
{
|
|
||||||
((Rom)item).HashData = tempHash;
|
|
||||||
}
|
|
||||||
else if (item.Type == ItemType.Disk)
|
|
||||||
{
|
|
||||||
((Disk)item).HashData = tempHash;
|
|
||||||
}
|
|
||||||
ParseAddHelper(item, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
|
ParseAddHelper(item, ref datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, clean, logger, out key);
|
||||||
}
|
}
|
||||||
// If the line is anything but a rom or disk and we're in a block
|
// If the line is anything but a rom or disk and we're in a block
|
||||||
@@ -1808,9 +1848,7 @@ namespace SabreTools.Helper
|
|||||||
DatItem lastrom = datdata.Files[key][index];
|
DatItem lastrom = datdata.Files[key][index];
|
||||||
if (lastrom.Type == ItemType.Rom)
|
if (lastrom.Type == ItemType.Rom)
|
||||||
{
|
{
|
||||||
Hash temphash = ((Rom)lastrom).HashData;
|
((Rom)lastrom).Size += size;
|
||||||
temphash.Size += size;
|
|
||||||
((Rom)lastrom).HashData = temphash;
|
|
||||||
}
|
}
|
||||||
datdata.Files[key].RemoveAt(index);
|
datdata.Files[key].RemoveAt(index);
|
||||||
datdata.Files[key].Add(lastrom);
|
datdata.Files[key].Add(lastrom);
|
||||||
@@ -1953,9 +1991,7 @@ namespace SabreTools.Helper
|
|||||||
DatItem lastrom = datdata.Files[key][index];
|
DatItem lastrom = datdata.Files[key][index];
|
||||||
if (lastrom.Type == ItemType.Rom)
|
if (lastrom.Type == ItemType.Rom)
|
||||||
{
|
{
|
||||||
Hash temphash = ((Rom)lastrom).HashData;
|
((Rom)lastrom).Size += size;
|
||||||
temphash.Size += size;
|
|
||||||
((Rom)lastrom).HashData = temphash;
|
|
||||||
}
|
}
|
||||||
datdata.Files[key].RemoveAt(index);
|
datdata.Files[key].RemoveAt(index);
|
||||||
datdata.Files[key].Add(lastrom);
|
datdata.Files[key].Add(lastrom);
|
||||||
@@ -2048,30 +2084,28 @@ namespace SabreTools.Helper
|
|||||||
Rom itemRom = (Rom)item;
|
Rom itemRom = (Rom)item;
|
||||||
|
|
||||||
// Sanitize the hashes from null, hex sizes, and "true blank" strings
|
// Sanitize the hashes from null, hex sizes, and "true blank" strings
|
||||||
Hash tempItemHash = itemRom.HashData;
|
itemRom.CRC = Style.CleanHashData(itemRom.CRC, Constants.CRCLength);
|
||||||
tempItemHash.CRC = Style.CleanHashData(itemRom.HashData.CRC, Constants.CRCLength);
|
itemRom.MD5 = Style.CleanHashData(itemRom.MD5, Constants.MD5Length);
|
||||||
tempItemHash.MD5 = Style.CleanHashData(itemRom.HashData.MD5, Constants.MD5Length);
|
itemRom.SHA1 = Style.CleanHashData(itemRom.SHA1, Constants.SHA1Length);
|
||||||
tempItemHash.SHA1 = Style.CleanHashData(itemRom.HashData.SHA1, Constants.SHA1Length);
|
|
||||||
|
|
||||||
// If we have a rom and it's missing size AND the hashes match a 0-byte file, fill in the rest of the info
|
// If we have a rom and it's missing size AND the hashes match a 0-byte file, fill in the rest of the info
|
||||||
if ((tempItemHash.Size == 0 || tempItemHash.Size == -1)
|
if ((itemRom.Size == 0 || itemRom.Size == -1)
|
||||||
&& ((tempItemHash.CRC == Constants.CRCZero || tempItemHash.CRC == "")
|
&& ((itemRom.CRC == Constants.CRCZero || itemRom.CRC == "")
|
||||||
|| tempItemHash.MD5 == Constants.MD5Zero
|
|| itemRom.MD5 == Constants.MD5Zero
|
||||||
|| tempItemHash.SHA1 == Constants.SHA1Zero))
|
|| itemRom.SHA1 == Constants.SHA1Zero))
|
||||||
{
|
{
|
||||||
tempItemHash.Size = Constants.SizeZero;
|
itemRom.Size = Constants.SizeZero;
|
||||||
tempItemHash.CRC = Constants.CRCZero;
|
itemRom.CRC = Constants.CRCZero;
|
||||||
tempItemHash.MD5 = Constants.MD5Zero;
|
itemRom.MD5 = Constants.MD5Zero;
|
||||||
tempItemHash.SHA1 = Constants.SHA1Zero;
|
itemRom.SHA1 = Constants.SHA1Zero;
|
||||||
}
|
}
|
||||||
// If the file has no size and it's not the above case, skip and log
|
// If the file has no size and it's not the above case, skip and log
|
||||||
else if (itemRom.Type == ItemType.Rom && (tempItemHash.Size == 0 || tempItemHash.Size == -1))
|
else if (itemRom.Type == ItemType.Rom && (itemRom.Size == 0 || itemRom.Size == -1))
|
||||||
{
|
{
|
||||||
logger.Warning("Incomplete entry for \"" + itemRom.Name + "\" will be output as nodump");
|
logger.Warning("Incomplete entry for \"" + itemRom.Name + "\" will be output as nodump");
|
||||||
itemRom.Nodump = true;
|
itemRom.Nodump = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
itemRom.HashData = tempItemHash;
|
|
||||||
item = itemRom;
|
item = itemRom;
|
||||||
}
|
}
|
||||||
else if (item.Type == ItemType.Disk)
|
else if (item.Type == ItemType.Disk)
|
||||||
@@ -2079,11 +2113,9 @@ namespace SabreTools.Helper
|
|||||||
Disk itemDisk = (Disk)item;
|
Disk itemDisk = (Disk)item;
|
||||||
|
|
||||||
// Sanitize the hashes from null, hex sizes, and "true blank" strings
|
// Sanitize the hashes from null, hex sizes, and "true blank" strings
|
||||||
Hash tempItemHash = itemDisk.HashData;
|
itemDisk.MD5 = Style.CleanHashData(itemDisk.MD5, Constants.MD5Length);
|
||||||
tempItemHash.MD5 = Style.CleanHashData(itemDisk.HashData.MD5, Constants.MD5Length);
|
itemDisk.SHA1 = Style.CleanHashData(itemDisk.SHA1, Constants.SHA1Length);
|
||||||
tempItemHash.SHA1 = Style.CleanHashData(itemDisk.HashData.SHA1, Constants.SHA1Length);
|
|
||||||
|
|
||||||
itemDisk.HashData = tempItemHash;
|
|
||||||
item = itemDisk;
|
item = itemDisk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2109,15 +2141,6 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a disk, make sure that the value for size is -1
|
|
||||||
if (item.Type == ItemType.Disk)
|
|
||||||
{
|
|
||||||
logger.Log("Disk found: \"" + item.Name + "\"");
|
|
||||||
Hash tempDiskHash = ((Disk)item).HashData;
|
|
||||||
tempDiskHash.Size = -1;
|
|
||||||
((Disk)item).HashData = tempDiskHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (datdata.Files)
|
lock (datdata.Files)
|
||||||
{
|
{
|
||||||
// Get the key and add statistical data
|
// Get the key and add statistical data
|
||||||
@@ -2130,24 +2153,24 @@ namespace SabreTools.Helper
|
|||||||
key = item.Type.ToString();
|
key = item.Type.ToString();
|
||||||
break;
|
break;
|
||||||
case ItemType.Disk:
|
case ItemType.Disk:
|
||||||
key = ((Disk)item).HashData.Size + "-" + ((Disk)item).HashData.CRC;
|
key = ((Disk)item).MD5;
|
||||||
|
|
||||||
// Add statistical data
|
// Add statistical data
|
||||||
datdata.DiskCount += 1;
|
datdata.DiskCount += 1;
|
||||||
datdata.TotalSize += (((Disk)item).Nodump ? 0 : ((Disk)item).HashData.Size);
|
datdata.TotalSize += 0;
|
||||||
datdata.MD5Count += (String.IsNullOrEmpty(((Disk)item).HashData.MD5) ? 0 : 1);
|
datdata.MD5Count += (String.IsNullOrEmpty(((Disk)item).MD5) ? 0 : 1);
|
||||||
datdata.SHA1Count += (String.IsNullOrEmpty(((Disk)item).HashData.SHA1) ? 0 : 1);
|
datdata.SHA1Count += (String.IsNullOrEmpty(((Disk)item).SHA1) ? 0 : 1);
|
||||||
datdata.NodumpCount += (((Disk)item).Nodump ? 1 : 0);
|
datdata.NodumpCount += (((Disk)item).Nodump ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case ItemType.Rom:
|
case ItemType.Rom:
|
||||||
key = ((Rom)item).HashData.Size + "-" + ((Rom)item).HashData.CRC;
|
key = ((Rom)item).Size + "-" + ((Rom)item).CRC;
|
||||||
|
|
||||||
// Add statistical data
|
// Add statistical data
|
||||||
datdata.RomCount += 1;
|
datdata.RomCount += 1;
|
||||||
datdata.TotalSize += (((Rom)item).Nodump ? 0 : ((Rom)item).HashData.Size);
|
datdata.TotalSize += (((Rom)item).Nodump ? 0 : ((Rom)item).Size);
|
||||||
datdata.CRCCount += (String.IsNullOrEmpty(((Rom)item).HashData.CRC) ? 0 : 1);
|
datdata.CRCCount += (String.IsNullOrEmpty(((Rom)item).CRC) ? 0 : 1);
|
||||||
datdata.MD5Count += (String.IsNullOrEmpty(((Rom)item).HashData.MD5) ? 0 : 1);
|
datdata.MD5Count += (String.IsNullOrEmpty(((Rom)item).MD5) ? 0 : 1);
|
||||||
datdata.SHA1Count += (String.IsNullOrEmpty(((Rom)item).HashData.SHA1) ? 0 : 1);
|
datdata.SHA1Count += (String.IsNullOrEmpty(((Rom)item).SHA1) ? 0 : 1);
|
||||||
datdata.NodumpCount += (((Rom)item).Nodump ? 1 : 0);
|
datdata.NodumpCount += (((Rom)item).Nodump ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -2962,10 +2985,10 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||||
if (rom.Type == ItemType.Rom
|
if (rom.Type == ItemType.Rom
|
||||||
&& ((Rom)rom).HashData.Size == -1
|
&& ((Rom)rom).Size == -1
|
||||||
&& ((Rom)rom).HashData.CRC == "null"
|
&& ((Rom)rom).CRC == "null"
|
||||||
&& ((Rom)rom).HashData.MD5 == "null"
|
&& ((Rom)rom).MD5 == "null"
|
||||||
&& ((Rom)rom).HashData.SHA1 == "null")
|
&& ((Rom)rom).SHA1 == "null")
|
||||||
{
|
{
|
||||||
logger.Log("Empty folder found: " + rom.MachineName);
|
logger.Log("Empty folder found: " + rom.MachineName);
|
||||||
|
|
||||||
@@ -2973,12 +2996,10 @@ namespace SabreTools.Helper
|
|||||||
if (outputFormat != OutputFormat.SabreDat && outputFormat != OutputFormat.MissFile)
|
if (outputFormat != OutputFormat.SabreDat && outputFormat != OutputFormat.MissFile)
|
||||||
{
|
{
|
||||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||||
Hash tempHash = ((Rom)rom).HashData;
|
((Rom)rom).Size = Constants.SizeZero;
|
||||||
tempHash.Size = Constants.SizeZero;
|
((Rom)rom).CRC = Constants.CRCZero;
|
||||||
tempHash.CRC = Constants.CRCZero;
|
((Rom)rom).MD5 = Constants.MD5Zero;
|
||||||
tempHash.MD5 = Constants.MD5Zero;
|
((Rom)rom).SHA1 = Constants.SHA1Zero;
|
||||||
tempHash.SHA1 = Constants.SHA1Zero;
|
|
||||||
((Rom)rom).HashData = tempHash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, set the new path and such, write out, and continue
|
// Otherwise, set the new path and such, write out, and continue
|
||||||
@@ -3310,7 +3331,7 @@ namespace SabreTools.Helper
|
|||||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||||
if (ignoreblanks
|
if (ignoreblanks
|
||||||
&& (rom.Type == ItemType.Rom
|
&& (rom.Type == ItemType.Rom
|
||||||
&& (((Rom)rom).HashData.Size == 0 || ((Rom)rom).HashData.Size == -1)))
|
&& (((Rom)rom).Size == 0 || ((Rom)rom).Size == -1)))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -3337,8 +3358,8 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
case ItemType.Disk:
|
case ItemType.Disk:
|
||||||
state += "\tdisk ( name \"" + rom.Name + "\""
|
state += "\tdisk ( name \"" + rom.Name + "\""
|
||||||
+ (!String.IsNullOrEmpty(((Disk)rom).HashData.MD5) ? " md5 " + ((Disk)rom).HashData.MD5.ToLowerInvariant() : "")
|
+ (!String.IsNullOrEmpty(((Disk)rom).MD5) ? " md5 " + ((Disk)rom).MD5.ToLowerInvariant() : "")
|
||||||
+ (!String.IsNullOrEmpty(((Disk)rom).HashData.SHA1) ? " sha1 " + ((Disk)rom).HashData.SHA1.ToLowerInvariant() : "")
|
+ (!String.IsNullOrEmpty(((Disk)rom).SHA1) ? " sha1 " + ((Disk)rom).SHA1.ToLowerInvariant() : "")
|
||||||
+ (((Disk)rom).Nodump ? " flags nodump" : "")
|
+ (((Disk)rom).Nodump ? " flags nodump" : "")
|
||||||
+ " )\n";
|
+ " )\n";
|
||||||
break;
|
break;
|
||||||
@@ -3354,10 +3375,10 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
case ItemType.Rom:
|
case ItemType.Rom:
|
||||||
state += "\trom ( name \"" + rom.Name + "\""
|
state += "\trom ( name \"" + rom.Name + "\""
|
||||||
+ (((Rom)rom).HashData.Size != -1 ? " size " + ((Rom)rom).HashData.Size : "")
|
+ (((Rom)rom).Size != -1 ? " size " + ((Rom)rom).Size : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).HashData.CRC) ? " crc " + ((Rom)rom).HashData.CRC.ToLowerInvariant() : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).CRC) ? " crc " + ((Rom)rom).CRC.ToLowerInvariant() : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).HashData.MD5) ? " md5 " + ((Rom)rom).HashData.MD5.ToLowerInvariant() : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).MD5) ? " md5 " + ((Rom)rom).MD5.ToLowerInvariant() : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).HashData.SHA1) ? " sha1 " + ((Rom)rom).HashData.SHA1.ToLowerInvariant() : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).SHA1) ? " sha1 " + ((Rom)rom).SHA1.ToLowerInvariant() : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).Date) ? " date \"" + ((Rom)rom).Date + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).Date) ? " date \"" + ((Rom)rom).Date + "\"" : "")
|
||||||
+ (((Rom)rom).Nodump ? " flags nodump" : "")
|
+ (((Rom)rom).Nodump ? " flags nodump" : "")
|
||||||
+ " )\n";
|
+ " )\n";
|
||||||
@@ -3385,17 +3406,17 @@ namespace SabreTools.Helper
|
|||||||
pre = pre
|
pre = pre
|
||||||
.Replace("%game%", rom.MachineName)
|
.Replace("%game%", rom.MachineName)
|
||||||
.Replace("%name%", rom.Name)
|
.Replace("%name%", rom.Name)
|
||||||
.Replace("%crc%", ((Rom)rom).HashData.CRC)
|
.Replace("%crc%", ((Rom)rom).CRC)
|
||||||
.Replace("%md5%", ((Rom)rom).HashData.MD5)
|
.Replace("%md5%", ((Rom)rom).MD5)
|
||||||
.Replace("%sha1%", ((Rom)rom).HashData.SHA1)
|
.Replace("%sha1%", ((Rom)rom).SHA1)
|
||||||
.Replace("%size%", ((Rom)rom).HashData.Size.ToString());
|
.Replace("%size%", ((Rom)rom).Size.ToString());
|
||||||
post = post
|
post = post
|
||||||
.Replace("%game%", rom.MachineName)
|
.Replace("%game%", rom.MachineName)
|
||||||
.Replace("%name%", rom.Name)
|
.Replace("%name%", rom.Name)
|
||||||
.Replace("%crc%", ((Rom)rom).HashData.CRC)
|
.Replace("%crc%", ((Rom)rom).CRC)
|
||||||
.Replace("%md5%", ((Rom)rom).HashData.MD5)
|
.Replace("%md5%", ((Rom)rom).MD5)
|
||||||
.Replace("%sha1%", ((Rom)rom).HashData.SHA1)
|
.Replace("%sha1%", ((Rom)rom).SHA1)
|
||||||
.Replace("%size%", ((Rom)rom).HashData.Size.ToString());
|
.Replace("%size%", ((Rom)rom).Size.ToString());
|
||||||
}
|
}
|
||||||
else if (rom.Type == ItemType.Disk)
|
else if (rom.Type == ItemType.Disk)
|
||||||
{
|
{
|
||||||
@@ -3403,13 +3424,13 @@ namespace SabreTools.Helper
|
|||||||
pre = pre
|
pre = pre
|
||||||
.Replace("%game%", rom.MachineName)
|
.Replace("%game%", rom.MachineName)
|
||||||
.Replace("%name%", rom.Name)
|
.Replace("%name%", rom.Name)
|
||||||
.Replace("%md5%", ((Disk)rom).HashData.MD5)
|
.Replace("%md5%", ((Disk)rom).MD5)
|
||||||
.Replace("%sha1%", ((Disk)rom).HashData.SHA1);
|
.Replace("%sha1%", ((Disk)rom).SHA1);
|
||||||
post = post
|
post = post
|
||||||
.Replace("%game%", rom.MachineName)
|
.Replace("%game%", rom.MachineName)
|
||||||
.Replace("%name%", rom.Name)
|
.Replace("%name%", rom.Name)
|
||||||
.Replace("%md5%", ((Disk)rom).HashData.MD5)
|
.Replace("%md5%", ((Disk)rom).MD5)
|
||||||
.Replace("%sha1%", ((Disk)rom).HashData.SHA1);
|
.Replace("%sha1%", ((Disk)rom).SHA1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're in Romba mode, the state is consistent
|
// If we're in Romba mode, the state is consistent
|
||||||
@@ -3418,26 +3439,26 @@ namespace SabreTools.Helper
|
|||||||
if (rom.Type == ItemType.Rom)
|
if (rom.Type == ItemType.Rom)
|
||||||
{
|
{
|
||||||
// We can only write out if there's a SHA-1
|
// We can only write out if there's a SHA-1
|
||||||
if (((Rom)rom).HashData.SHA1 != "")
|
if (((Rom)rom).SHA1 != "")
|
||||||
{
|
{
|
||||||
string name = ((Rom)rom).HashData.SHA1.Substring(0, 2)
|
string name = ((Rom)rom).SHA1.Substring(0, 2)
|
||||||
+ "/" + ((Rom)rom).HashData.SHA1.Substring(2, 2)
|
+ "/" + ((Rom)rom).SHA1.Substring(2, 2)
|
||||||
+ "/" + ((Rom)rom).HashData.SHA1.Substring(4, 2)
|
+ "/" + ((Rom)rom).SHA1.Substring(4, 2)
|
||||||
+ "/" + ((Rom)rom).HashData.SHA1.Substring(6, 2)
|
+ "/" + ((Rom)rom).SHA1.Substring(6, 2)
|
||||||
+ "/" + ((Rom)rom).HashData.SHA1 + ".gz";
|
+ "/" + ((Rom)rom).SHA1 + ".gz";
|
||||||
state += pre + name + post + "\n";
|
state += pre + name + post + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (rom.Type == ItemType.Disk)
|
else if (rom.Type == ItemType.Disk)
|
||||||
{
|
{
|
||||||
// We can only write out if there's a SHA-1
|
// We can only write out if there's a SHA-1
|
||||||
if (((Disk)rom).HashData.SHA1 != "")
|
if (((Disk)rom).SHA1 != "")
|
||||||
{
|
{
|
||||||
string name = ((Disk)rom).HashData.SHA1.Substring(0, 2)
|
string name = ((Disk)rom).SHA1.Substring(0, 2)
|
||||||
+ "/" + ((Disk)rom).HashData.SHA1.Substring(2, 2)
|
+ "/" + ((Disk)rom).SHA1.Substring(2, 2)
|
||||||
+ "/" + ((Disk)rom).HashData.SHA1.Substring(4, 2)
|
+ "/" + ((Disk)rom).SHA1.Substring(4, 2)
|
||||||
+ "/" + ((Disk)rom).HashData.SHA1.Substring(6, 2)
|
+ "/" + ((Disk)rom).SHA1.Substring(6, 2)
|
||||||
+ "/" + ((Disk)rom).HashData.SHA1 + ".gz";
|
+ "/" + ((Disk)rom).SHA1 + ".gz";
|
||||||
state += pre + name + post + "\n";
|
state += pre + name + post + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3457,10 +3478,10 @@ namespace SabreTools.Helper
|
|||||||
+ separator + "\"rom\""
|
+ separator + "\"rom\""
|
||||||
+ separator + "\"" + rom.Name + "\""
|
+ separator + "\"" + rom.Name + "\""
|
||||||
+ separator + "\"\""
|
+ separator + "\"\""
|
||||||
+ separator + "\"" + ((Rom)rom).HashData.Size + "\""
|
+ separator + "\"" + ((Rom)rom).Size + "\""
|
||||||
+ separator + "\"" + ((Rom)rom).HashData.CRC + "\""
|
+ separator + "\"" + ((Rom)rom).CRC + "\""
|
||||||
+ separator + "\"" + ((Rom)rom).HashData.MD5 + "\""
|
+ separator + "\"" + ((Rom)rom).MD5 + "\""
|
||||||
+ separator + "\"" + ((Rom)rom).HashData.SHA1 + "\""
|
+ separator + "\"" + ((Rom)rom).SHA1 + "\""
|
||||||
+ separator + (((Rom)rom).Nodump ? "\"Nodump\"" : "\"\"");
|
+ separator + (((Rom)rom).Nodump ? "\"Nodump\"" : "\"\"");
|
||||||
state += pre + inline + post + "\n";
|
state += pre + inline + post + "\n";
|
||||||
}
|
}
|
||||||
@@ -3476,8 +3497,8 @@ namespace SabreTools.Helper
|
|||||||
+ separator + "\"" + rom.Name + "\""
|
+ separator + "\"" + rom.Name + "\""
|
||||||
+ separator + "\"\""
|
+ separator + "\"\""
|
||||||
+ separator + "\"\""
|
+ separator + "\"\""
|
||||||
+ separator + "\"" + ((Disk)rom).HashData.MD5 + "\""
|
+ separator + "\"" + ((Disk)rom).MD5 + "\""
|
||||||
+ separator + "\"" + ((Disk)rom).HashData.SHA1 + "\""
|
+ separator + "\"" + ((Disk)rom).SHA1 + "\""
|
||||||
+ separator + (((Disk)rom).Nodump ? "\"Nodump\"" : "\"\"");
|
+ separator + (((Disk)rom).Nodump ? "\"Nodump\"" : "\"\"");
|
||||||
state += pre + inline + post + "\n";
|
state += pre + inline + post + "\n";
|
||||||
}
|
}
|
||||||
@@ -3520,27 +3541,27 @@ namespace SabreTools.Helper
|
|||||||
case OutputFormat.RedumpMD5:
|
case OutputFormat.RedumpMD5:
|
||||||
if (rom.Type == ItemType.Rom)
|
if (rom.Type == ItemType.Rom)
|
||||||
{
|
{
|
||||||
state += ((Rom)rom).HashData.MD5 + " *" + rom.Name + "\n";
|
state += ((Rom)rom).MD5 + " *" + rom.Name + "\n";
|
||||||
}
|
}
|
||||||
else if (rom.Type == ItemType.Disk)
|
else if (rom.Type == ItemType.Disk)
|
||||||
{
|
{
|
||||||
state += ((Disk)rom).HashData.MD5 + " *" + rom.Name + "\n";
|
state += ((Disk)rom).MD5 + " *" + rom.Name + "\n";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OutputFormat.RedumpSFV:
|
case OutputFormat.RedumpSFV:
|
||||||
if (rom.Type == ItemType.Rom)
|
if (rom.Type == ItemType.Rom)
|
||||||
{
|
{
|
||||||
state += rom.Name + " " + ((Rom)rom).HashData.CRC + "\n";
|
state += rom.Name + " " + ((Rom)rom).CRC + "\n";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OutputFormat.RedumpSHA1:
|
case OutputFormat.RedumpSHA1:
|
||||||
if (rom.Type == ItemType.Rom)
|
if (rom.Type == ItemType.Rom)
|
||||||
{
|
{
|
||||||
state += ((Rom)rom).HashData.SHA1 + " *" + rom.Name + "\n";
|
state += ((Rom)rom).SHA1 + " *" + rom.Name + "\n";
|
||||||
}
|
}
|
||||||
else if (rom.Type == ItemType.Disk)
|
else if (rom.Type == ItemType.Disk)
|
||||||
{
|
{
|
||||||
state += ((Disk)rom).HashData.SHA1 + " *" + rom.Name + "\n";
|
state += ((Disk)rom).SHA1 + " *" + rom.Name + "\n";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OutputFormat.RomCenter:
|
case OutputFormat.RomCenter:
|
||||||
@@ -3551,8 +3572,8 @@ namespace SabreTools.Helper
|
|||||||
"¬" + HttpUtility.HtmlEncode(rom.MachineName) +
|
"¬" + HttpUtility.HtmlEncode(rom.MachineName) +
|
||||||
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) +
|
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) +
|
||||||
"¬" + HttpUtility.HtmlEncode(rom.Name) +
|
"¬" + HttpUtility.HtmlEncode(rom.Name) +
|
||||||
"¬" + ((Rom)rom).HashData.CRC.ToLowerInvariant() +
|
"¬" + ((Rom)rom).CRC.ToLowerInvariant() +
|
||||||
"¬" + (((Rom)rom).HashData.Size != -1 ? ((Rom)rom).HashData.Size.ToString() : "") + "¬¬¬\n";
|
"¬" + (((Rom)rom).Size != -1 ? ((Rom)rom).Size.ToString() : "") + "¬¬¬\n";
|
||||||
}
|
}
|
||||||
else if (rom.Type == ItemType.Disk)
|
else if (rom.Type == ItemType.Disk)
|
||||||
{
|
{
|
||||||
@@ -3589,8 +3610,8 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
case ItemType.Disk:
|
case ItemType.Disk:
|
||||||
state += "<file type=\"disk\" name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
|
state += "<file type=\"disk\" name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
|
||||||
+ (!String.IsNullOrEmpty(((Disk)rom).HashData.MD5) ? " md5=\"" + ((Disk)rom).HashData.MD5.ToLowerInvariant() + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Disk)rom).MD5) ? " md5=\"" + ((Disk)rom).MD5.ToLowerInvariant() + "\"" : "")
|
||||||
+ (!String.IsNullOrEmpty(((Disk)rom).HashData.SHA1) ? " sha1=\"" + ((Disk)rom).HashData.SHA1.ToLowerInvariant() + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Disk)rom).SHA1) ? " sha1=\"" + ((Disk)rom).SHA1.ToLowerInvariant() + "\"" : "")
|
||||||
+ (((Disk)rom).Nodump ? prefix + "/>\n" + prefix + "\t<flags>\n" +
|
+ (((Disk)rom).Nodump ? prefix + "/>\n" + prefix + "\t<flags>\n" +
|
||||||
prefix + "\t\t<flag name=\"status\" value=\"nodump\"/>\n" +
|
prefix + "\t\t<flag name=\"status\" value=\"nodump\"/>\n" +
|
||||||
prefix + "\t</flags>\n" +
|
prefix + "\t</flags>\n" +
|
||||||
@@ -3608,10 +3629,10 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
case ItemType.Rom:
|
case ItemType.Rom:
|
||||||
state += "<file type=\"rom\" name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
|
state += "<file type=\"rom\" name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
|
||||||
+ (((Rom)rom).HashData.Size != -1 ? " size=\"" + ((Rom)rom).HashData.Size + "\"" : "")
|
+ (((Rom)rom).Size != -1 ? " size=\"" + ((Rom)rom).Size + "\"" : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).HashData.CRC) ? " crc=" + ((Rom)rom).HashData.CRC.ToLowerInvariant() + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).CRC) ? " crc=" + ((Rom)rom).CRC.ToLowerInvariant() + "\"" : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).HashData.MD5) ? " md5=" + ((Rom)rom).HashData.MD5.ToLowerInvariant() + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).MD5) ? " md5=" + ((Rom)rom).MD5.ToLowerInvariant() + "\"" : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).HashData.SHA1) ? " sha1=" + ((Rom)rom).HashData.SHA1.ToLowerInvariant() + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).SHA1) ? " sha1=" + ((Rom)rom).SHA1.ToLowerInvariant() + "\"" : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).Date) ? " date=\"" + ((Rom)rom).Date + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).Date) ? " date=\"" + ((Rom)rom).Date + "\"" : "")
|
||||||
+ (((Rom)rom).Nodump ? prefix + "/>\n" + prefix + "\t<flags>\n" +
|
+ (((Rom)rom).Nodump ? prefix + "/>\n" + prefix + "\t<flags>\n" +
|
||||||
prefix + "\t\t<flag name=\"status\" value=\"nodump\"/>\n" +
|
prefix + "\t\t<flag name=\"status\" value=\"nodump\"/>\n" +
|
||||||
@@ -3641,8 +3662,8 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
case ItemType.Disk:
|
case ItemType.Disk:
|
||||||
state += "\t\t<disk name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
|
state += "\t\t<disk name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
|
||||||
+ (!String.IsNullOrEmpty(((Disk)rom).HashData.MD5) ? " md5=\"" + ((Disk)rom).HashData.MD5.ToLowerInvariant() + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Disk)rom).MD5) ? " md5=\"" + ((Disk)rom).MD5.ToLowerInvariant() + "\"" : "")
|
||||||
+ (!String.IsNullOrEmpty(((Disk)rom).HashData.SHA1) ? " sha1=\"" + ((Disk)rom).HashData.SHA1.ToLowerInvariant() + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Disk)rom).SHA1) ? " sha1=\"" + ((Disk)rom).SHA1.ToLowerInvariant() + "\"" : "")
|
||||||
+ (((Disk)rom).Nodump ? " status=\"nodump\"" : "")
|
+ (((Disk)rom).Nodump ? " status=\"nodump\"" : "")
|
||||||
+ "/>\n";
|
+ "/>\n";
|
||||||
break;
|
break;
|
||||||
@@ -3658,10 +3679,10 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
case ItemType.Rom:
|
case ItemType.Rom:
|
||||||
state += "\t\t<rom name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
|
state += "\t\t<rom name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
|
||||||
+ (((Rom)rom).HashData.Size != -1 ? " size=\"" + ((Rom)rom).HashData.Size + "\"" : "")
|
+ (((Rom)rom).Size != -1 ? " size=\"" + ((Rom)rom).Size + "\"" : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).HashData.CRC) ? " crc=" + ((Rom)rom).HashData.CRC.ToLowerInvariant() + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).CRC) ? " crc=" + ((Rom)rom).CRC.ToLowerInvariant() + "\"" : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).HashData.MD5) ? " md5=" + ((Rom)rom).HashData.MD5.ToLowerInvariant() + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).MD5) ? " md5=" + ((Rom)rom).MD5.ToLowerInvariant() + "\"" : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).HashData.SHA1) ? " sha1=" + ((Rom)rom).HashData.SHA1.ToLowerInvariant() + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).SHA1) ? " sha1=" + ((Rom)rom).SHA1.ToLowerInvariant() + "\"" : "")
|
||||||
+ (!String.IsNullOrEmpty(((Rom)rom).Date) ? " date=\"" + ((Rom)rom).Date + "\"" : "")
|
+ (!String.IsNullOrEmpty(((Rom)rom).Date) ? " date=\"" + ((Rom)rom).Date + "\"" : "")
|
||||||
+ (((Rom)rom).Nodump ? " status=\"nodump\"" : "")
|
+ (((Rom)rom).Nodump ? " status=\"nodump\"" : "")
|
||||||
+ "/>\n";
|
+ "/>\n";
|
||||||
@@ -4074,8 +4095,8 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the file has a SHA-1
|
// If the file has a SHA-1
|
||||||
else if ((rom.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)rom).HashData.SHA1))
|
else if ((rom.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)rom).SHA1))
|
||||||
|| (rom.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)rom).HashData.SHA1)))
|
|| (rom.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)rom).SHA1)))
|
||||||
{
|
{
|
||||||
if (sha1.Files.ContainsKey(key))
|
if (sha1.Files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -4089,8 +4110,8 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the file has no SHA-1 but has an MD5
|
// If the file has no SHA-1 but has an MD5
|
||||||
else if ((rom.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)rom).HashData.MD5))
|
else if ((rom.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)rom).MD5))
|
||||||
|| (rom.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)rom).HashData.MD5)))
|
|| (rom.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)rom).MD5)))
|
||||||
{
|
{
|
||||||
if (md5.Files.ContainsKey(key))
|
if (md5.Files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -4104,8 +4125,8 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the file has no MD5 but a CRC
|
// If the file has no MD5 but a CRC
|
||||||
else if ((rom.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)rom).HashData.SHA1))
|
else if ((rom.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)rom).SHA1))
|
||||||
|| (rom.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)rom).HashData.SHA1)))
|
|| (rom.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)rom).SHA1)))
|
||||||
{
|
{
|
||||||
if (crc.Files.ContainsKey(key))
|
if (crc.Files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,24 +1,32 @@
|
|||||||
namespace SabreTools.Helper
|
using System;
|
||||||
|
|
||||||
|
namespace SabreTools.Helper
|
||||||
{
|
{
|
||||||
public class Disk : DatItem
|
public class Disk : DatItem
|
||||||
{
|
{
|
||||||
#region Private instance variables
|
#region Private instance variables
|
||||||
|
|
||||||
// Disk information
|
// Disk information
|
||||||
private Hash _hashData;
|
protected string _md5;
|
||||||
|
protected string _sha1;
|
||||||
// private string _merge;
|
// private string _merge;
|
||||||
// private DiskStatus _romStatus;
|
// private DiskStatus _romStatus;
|
||||||
private bool _nodump;
|
protected bool _nodump;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Publicly facing variables
|
#region Publicly facing variables
|
||||||
|
|
||||||
// Disk information
|
// Disk information
|
||||||
public Hash HashData
|
public string MD5
|
||||||
{
|
{
|
||||||
get { return _hashData; }
|
get { return _md5; }
|
||||||
set { _hashData = value; }
|
set { _md5 = value; }
|
||||||
|
}
|
||||||
|
public string SHA1
|
||||||
|
{
|
||||||
|
get { return _sha1; }
|
||||||
|
set { _sha1 = value; }
|
||||||
}
|
}
|
||||||
public bool Nodump
|
public bool Nodump
|
||||||
{
|
{
|
||||||
@@ -52,11 +60,8 @@
|
|||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
_itemType = ItemType.Disk;
|
_itemType = ItemType.Disk;
|
||||||
_hashData = new Hash
|
_md5 = md5.ToLowerInvariant();
|
||||||
{
|
_sha1 = sha1.ToLowerInvariant();
|
||||||
MD5 = md5.ToLowerInvariant(),
|
|
||||||
SHA1 = sha1.ToLowerInvariant(),
|
|
||||||
};
|
|
||||||
_nodump = nodump;
|
_nodump = nodump;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,11 +94,8 @@
|
|||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
_itemType = ItemType.Disk;
|
_itemType = ItemType.Disk;
|
||||||
_hashData = new Hash
|
_md5 = md5.ToLowerInvariant();
|
||||||
{
|
_sha1 = sha1.ToLowerInvariant();
|
||||||
MD5 = md5.ToLowerInvariant(),
|
|
||||||
SHA1 = sha1.ToLowerInvariant(),
|
|
||||||
};
|
|
||||||
_nodump = nodump;
|
_nodump = nodump;
|
||||||
_machineName = machineName;
|
_machineName = machineName;
|
||||||
_comment = comment;
|
_comment = comment;
|
||||||
@@ -136,7 +138,11 @@
|
|||||||
return dupefound;
|
return dupefound;
|
||||||
}
|
}
|
||||||
|
|
||||||
dupefound = _hashData.Equals(newOther.HashData, false);
|
if (((String.IsNullOrEmpty(_md5) || String.IsNullOrEmpty(newOther.MD5)) || this.MD5 == newOther.MD5) &&
|
||||||
|
((String.IsNullOrEmpty(this.SHA1) || String.IsNullOrEmpty(newOther.SHA1)) || this.SHA1 == newOther.SHA1))
|
||||||
|
{
|
||||||
|
dupefound = true;
|
||||||
|
}
|
||||||
|
|
||||||
return dupefound;
|
return dupefound;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
namespace SabreTools.Helper
|
using System;
|
||||||
|
|
||||||
|
namespace SabreTools.Helper
|
||||||
{
|
{
|
||||||
public class Rom : DatItem
|
public class Rom : Disk
|
||||||
{
|
{
|
||||||
#region Private instance variables
|
#region Private instance variables
|
||||||
|
|
||||||
// Rom information
|
// Rom information
|
||||||
private Hash _hashData;
|
protected long _size;
|
||||||
// private string _merge;
|
protected string _crc;
|
||||||
// private RomStatus _romStatus;
|
|
||||||
private bool _nodump;
|
|
||||||
private string _date;
|
private string _date;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -16,15 +16,15 @@
|
|||||||
#region Publicly facing variables
|
#region Publicly facing variables
|
||||||
|
|
||||||
// Rom information
|
// Rom information
|
||||||
public Hash HashData
|
public long Size
|
||||||
{
|
{
|
||||||
get { return _hashData; }
|
get { return _size; }
|
||||||
set { _hashData = value; }
|
set { _size = value; }
|
||||||
}
|
}
|
||||||
public bool Nodump
|
public string CRC
|
||||||
{
|
{
|
||||||
get { return _nodump; }
|
get { return _crc; }
|
||||||
set { _nodump = value; }
|
set { _crc = value; }
|
||||||
}
|
}
|
||||||
public string Date
|
public string Date
|
||||||
{
|
{
|
||||||
@@ -72,13 +72,10 @@
|
|||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
_itemType = ItemType.Rom;
|
_itemType = ItemType.Rom;
|
||||||
_hashData = new Hash
|
_size = size;
|
||||||
{
|
_crc = crc.ToLowerInvariant();
|
||||||
Size = size,
|
_md5 = md5.ToLowerInvariant();
|
||||||
CRC = crc.ToLowerInvariant(),
|
_sha1 = sha1.ToLowerInvariant();
|
||||||
MD5 = md5.ToLowerInvariant(),
|
|
||||||
SHA1 = sha1.ToLowerInvariant(),
|
|
||||||
};
|
|
||||||
_nodump = nodump;
|
_nodump = nodump;
|
||||||
_date = date;
|
_date = date;
|
||||||
}
|
}
|
||||||
@@ -115,13 +112,10 @@
|
|||||||
{
|
{
|
||||||
_name = name;
|
_name = name;
|
||||||
_itemType = ItemType.Rom;
|
_itemType = ItemType.Rom;
|
||||||
_hashData = new Hash
|
_size = size;
|
||||||
{
|
_crc = crc.ToLowerInvariant();
|
||||||
Size = size,
|
_md5 = md5.ToLowerInvariant();
|
||||||
CRC = crc.ToLowerInvariant(),
|
_sha1 = sha1.ToLowerInvariant();
|
||||||
MD5 = md5.ToLowerInvariant(),
|
|
||||||
SHA1 = sha1.ToLowerInvariant(),
|
|
||||||
};
|
|
||||||
_nodump = nodump;
|
_nodump = nodump;
|
||||||
_date = date;
|
_date = date;
|
||||||
_machineName = machineName;
|
_machineName = machineName;
|
||||||
@@ -165,7 +159,13 @@
|
|||||||
return dupefound;
|
return dupefound;
|
||||||
}
|
}
|
||||||
|
|
||||||
dupefound = _hashData.Equals(newOther.HashData, false);
|
if ((this.Size == newOther.Size) &&
|
||||||
|
((String.IsNullOrEmpty(this.CRC) || String.IsNullOrEmpty(newOther.CRC)) || this.CRC == newOther.CRC) &&
|
||||||
|
((String.IsNullOrEmpty(this.MD5) || String.IsNullOrEmpty(newOther.MD5)) || this.MD5 == newOther.MD5) &&
|
||||||
|
((String.IsNullOrEmpty(this.SHA1) || String.IsNullOrEmpty(newOther.SHA1)) || this.SHA1 == newOther.SHA1))
|
||||||
|
{
|
||||||
|
dupefound = true;
|
||||||
|
}
|
||||||
|
|
||||||
return dupefound;
|
return dupefound;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ JOIN checksums
|
|||||||
sldr.GetString(6), null, sldr.GetString(0), null, null, null, null, false, null, null, sldr.GetInt32(2),
|
sldr.GetString(6), null, sldr.GetString(0), null, null, null, null, false, null, null, sldr.GetInt32(2),
|
||||||
sldr.GetString(1), sldr.GetInt32(5), sldr.GetString(3));
|
sldr.GetString(1), sldr.GetInt32(5), sldr.GetString(3));
|
||||||
|
|
||||||
key = ((Disk)temp).HashData.Size + "-" + ((Disk)temp).HashData.CRC;
|
key = ((Disk)temp).MD5;
|
||||||
break;
|
break;
|
||||||
case "rom":
|
case "rom":
|
||||||
default:
|
default:
|
||||||
@@ -253,7 +253,7 @@ JOIN checksums
|
|||||||
sldr.GetString(13), sldr.GetString(6), null, sldr.GetString(6), null, sldr.GetString(0), null, null, null, null, false,
|
sldr.GetString(13), sldr.GetString(6), null, sldr.GetString(6), null, sldr.GetString(0), null, null, null, null, false,
|
||||||
null, null, sldr.GetInt32(2), sldr.GetString(1), sldr.GetInt32(5), sldr.GetString(3));
|
null, null, sldr.GetInt32(2), sldr.GetString(1), sldr.GetInt32(5), sldr.GetString(3));
|
||||||
|
|
||||||
key = ((Disk)temp).HashData.Size + "-" + ((Disk)temp).HashData.CRC;
|
key = ((Rom)temp).Size + "-" + ((Rom)temp).CRC;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ namespace SabreTools
|
|||||||
|
|
||||||
// Now add the information to the database if it's not already there
|
// Now add the information to the database if it's not already there
|
||||||
Rom rom = FileTools.GetSingleFileInfo(newfile);
|
Rom rom = FileTools.GetSingleFileInfo(newfile);
|
||||||
AddHeaderToDatabase(hstr, rom.HashData.SHA1, type);
|
AddHeaderToDatabase(hstr, rom.SHA1, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -191,7 +191,7 @@ namespace SabreTools
|
|||||||
// Then try to pull the corresponding headers from the database
|
// Then try to pull the corresponding headers from the database
|
||||||
string header = "";
|
string header = "";
|
||||||
|
|
||||||
string query = @"SELECT header, type FROM data WHERE sha1='" + rom.HashData.SHA1 + "'";
|
string query = @"SELECT header, type FROM data WHERE sha1='" + rom.SHA1 + "'";
|
||||||
using (SqliteConnection dbc = new SqliteConnection(Constants.HeadererConnectionString))
|
using (SqliteConnection dbc = new SqliteConnection(Constants.HeadererConnectionString))
|
||||||
{
|
{
|
||||||
dbc.Open();
|
dbc.Open();
|
||||||
|
|||||||
@@ -520,10 +520,10 @@ SELECT files.id FROM files
|
|||||||
WHERE files.name='" + rom.Name.Replace("'", "''") + @"'
|
WHERE files.name='" + rom.Name.Replace("'", "''") + @"'
|
||||||
AND files.type='" + rom.Type + @"'
|
AND files.type='" + rom.Type + @"'
|
||||||
AND files.setid=" + gameid +
|
AND files.setid=" + gameid +
|
||||||
" AND checksums.size=" + rom.HashData.Size +
|
" AND checksums.size=" + rom.Size +
|
||||||
" AND checksums.crc='" + rom.HashData.CRC + "'" +
|
" AND checksums.crc='" + rom.CRC + "'" +
|
||||||
" AND checksums.md5='" + rom.HashData.MD5 + "'" +
|
" AND checksums.md5='" + rom.MD5 + "'" +
|
||||||
" AND checksums.sha1='" + rom.HashData.SHA1 + "'";
|
" AND checksums.sha1='" + rom.SHA1 + "'";
|
||||||
|
|
||||||
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
||||||
{
|
{
|
||||||
@@ -536,7 +536,7 @@ SELECT files.id FROM files
|
|||||||
INSERT INTO files (setid, name, type, lastupdated)
|
INSERT INTO files (setid, name, type, lastupdated)
|
||||||
VALUES (" + gameid + ", '" + rom.Name.Replace("'", "''") + "', '" + rom.Type + "', '" + date + @"');
|
VALUES (" + gameid + ", '" + rom.Name.Replace("'", "''") + "', '" + rom.Type + "', '" + date + @"');
|
||||||
INSERT INTO checksums (file, size, crc, md5, sha1)
|
INSERT INTO checksums (file, size, crc, md5, sha1)
|
||||||
VALUES ((SELECT last_insertConstants.Rowid()), " + rom.HashData.Size + ", '" + rom.HashData.CRC + "'" + ", '" + rom.HashData.MD5 + "'" + ", '" + rom.HashData.SHA1 + @"');
|
VALUES ((SELECT last_insertConstants.Rowid()), " + rom.Size + ", '" + rom.CRC + "'" + ", '" + rom.MD5 + "'" + ", '" + rom.SHA1 + @"');
|
||||||
COMMIT;";
|
COMMIT;";
|
||||||
using (SqliteCommand slc2 = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc2 = new SqliteCommand(query, dbc))
|
||||||
{
|
{
|
||||||
@@ -594,7 +594,7 @@ COMMIT;";
|
|||||||
|
|
||||||
// Retrieve or insert the hash
|
// Retrieve or insert the hash
|
||||||
long hashid = -1;
|
long hashid = -1;
|
||||||
string query = "SELECT id FROM hash WHERE size=" + rom.HashData.Size + " AND crc='" + rom.HashData.CRC + "' AND md5='" + rom.HashData.MD5 + "' AND sha1='" + rom.HashData.SHA1 + "'";
|
string query = "SELECT id FROM hash WHERE size=" + rom.Size + " AND crc='" + rom.CRC + "' AND md5='" + rom.MD5 + "' AND sha1='" + rom.SHA1 + "'";
|
||||||
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc = new SqliteCommand(query, dbc))
|
||||||
{
|
{
|
||||||
using (SqliteDataReader sldr = slc.ExecuteReader())
|
using (SqliteDataReader sldr = slc.ExecuteReader())
|
||||||
@@ -603,7 +603,7 @@ COMMIT;";
|
|||||||
if (!sldr.HasRows)
|
if (!sldr.HasRows)
|
||||||
{
|
{
|
||||||
query = "INSERT INTO hash (size, crc, md5, sha1)" +
|
query = "INSERT INTO hash (size, crc, md5, sha1)" +
|
||||||
" VALUES (" + rom.HashData.Size + ", '" + rom.HashData.CRC + "', '" + rom.HashData.MD5 + "', '" + rom.HashData.SHA1 + "')";
|
" VALUES (" + rom.Size + ", '" + rom.CRC + "', '" + rom.MD5 + "', '" + rom.SHA1 + "')";
|
||||||
|
|
||||||
using (SqliteCommand slc2 = new SqliteCommand(query, dbc))
|
using (SqliteCommand slc2 = new SqliteCommand(query, dbc))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ namespace SabreTools.Helper
|
|||||||
if (rom.SourceID == 99)
|
if (rom.SourceID == 99)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
string key = rom.HashData.Size + "-" + rom.HashData.CRC;
|
string key = rom.Size + "-" + rom.CRC;
|
||||||
if (_matched.Files.ContainsKey(key))
|
if (_matched.Files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
_matched.Files[key].Add(rom);
|
_matched.Files[key].Add(rom);
|
||||||
@@ -470,7 +470,7 @@ namespace SabreTools.Helper
|
|||||||
rom.MachineName = Path.GetDirectoryName(Path.GetFullPath(file));
|
rom.MachineName = Path.GetDirectoryName(Path.GetFullPath(file));
|
||||||
|
|
||||||
// Add the rom information to the Dat
|
// Add the rom information to the Dat
|
||||||
string key = rom.HashData.Size + "-" + rom.HashData.CRC;
|
string key = rom.Size + "-" + rom.CRC;
|
||||||
if (matchdat.Files.ContainsKey(key))
|
if (matchdat.Files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
matchdat.Files[key].Add(rom);
|
matchdat.Files[key].Add(rom);
|
||||||
@@ -497,7 +497,7 @@ namespace SabreTools.Helper
|
|||||||
romNH.MachineName = rom.MachineName;
|
romNH.MachineName = rom.MachineName;
|
||||||
|
|
||||||
// Add the rom information to the Dat
|
// Add the rom information to the Dat
|
||||||
key = romNH.HashData.Size + "-" + romNH.HashData.CRC;
|
key = romNH.Size + "-" + romNH.CRC;
|
||||||
if (matchdat.Files.ContainsKey(key))
|
if (matchdat.Files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
matchdat.Files[key].Add(romNH);
|
matchdat.Files[key].Add(romNH);
|
||||||
@@ -555,7 +555,7 @@ namespace SabreTools.Helper
|
|||||||
_logger.Log("Matched name: " + found.Name);
|
_logger.Log("Matched name: " + found.Name);
|
||||||
|
|
||||||
// Add rom to the matched list
|
// Add rom to the matched list
|
||||||
string key = found.HashData.Size + "-" + found.HashData.CRC;
|
string key = found.Size + "-" + found.CRC;
|
||||||
if (_matched.Files.ContainsKey(key))
|
if (_matched.Files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
_matched.Files[key].Add(found);
|
_matched.Files[key].Add(found);
|
||||||
@@ -576,7 +576,7 @@ namespace SabreTools.Helper
|
|||||||
Directory.CreateDirectory(gamedir);
|
Directory.CreateDirectory(gamedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.HashData.SHA1 : found.Name) + "'");
|
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.SHA1 : found.Name) + "'");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Copy(input, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
File.Copy(input, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
||||||
@@ -623,7 +623,7 @@ namespace SabreTools.Helper
|
|||||||
foreach (Rom found in founddroms)
|
foreach (Rom found in founddroms)
|
||||||
{
|
{
|
||||||
// Add rom to the matched list
|
// Add rom to the matched list
|
||||||
string key = found.HashData.Size + "-" + found.HashData.CRC;
|
string key = found.Size + "-" + found.CRC;
|
||||||
if (_matched.Files.ContainsKey(key))
|
if (_matched.Files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
_matched.Files[key].Add(found);
|
_matched.Files[key].Add(found);
|
||||||
@@ -647,7 +647,7 @@ namespace SabreTools.Helper
|
|||||||
Directory.CreateDirectory(gamedir);
|
Directory.CreateDirectory(gamedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.HashData.SHA1 : found.Name) + "'");
|
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.SHA1 : found.Name) + "'");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Copy(newinput, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
File.Copy(newinput, Path.Combine(gamedir, Path.GetFileName(found.Name)));
|
||||||
@@ -672,11 +672,11 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
// Then output the headered rom (renamed)
|
// Then output the headered rom (renamed)
|
||||||
Rom newfound = found;
|
Rom newfound = found;
|
||||||
newfound.Name = Path.GetFileNameWithoutExtension(newfound.Name) + " (" + rom.HashData.CRC + ")" + Path.GetExtension(newfound.Name);
|
newfound.Name = Path.GetFileNameWithoutExtension(newfound.Name) + " (" + rom.CRC + ")" + Path.GetExtension(newfound.Name);
|
||||||
newfound.HashData = rom.HashData;
|
newfound = rom;
|
||||||
|
|
||||||
// Add rom to the matched list
|
// Add rom to the matched list
|
||||||
key = newfound.HashData.Size + "-" + newfound.HashData.CRC;
|
key = newfound.Size + "-" + newfound.CRC;
|
||||||
if (_matched.Files.ContainsKey(key))
|
if (_matched.Files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
_matched.Files[key].Add(newfound);
|
_matched.Files[key].Add(newfound);
|
||||||
@@ -755,7 +755,7 @@ namespace SabreTools.Helper
|
|||||||
foreach (Rom found in foundroms)
|
foreach (Rom found in foundroms)
|
||||||
{
|
{
|
||||||
// Add rom to the matched list
|
// Add rom to the matched list
|
||||||
string key = found.HashData.Size + "-" + found.HashData.CRC;
|
string key = found.Size + "-" + found.CRC;
|
||||||
if (_matched.Files.ContainsKey(key))
|
if (_matched.Files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
_matched.Files[key].Add(found);
|
_matched.Files[key].Add(found);
|
||||||
@@ -790,7 +790,7 @@ namespace SabreTools.Helper
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Copy file between archives
|
// Copy file between archives
|
||||||
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.HashData.SHA1 : found.Name) + "'");
|
_logger.Log("Rebuilding file '" + Path.GetFileName(rom.Name) + "' to '" + (_torrentX == false ? found.SHA1 : found.Name) + "'");
|
||||||
|
|
||||||
if (Build.MonoEnvironment || _torrentX == false)
|
if (Build.MonoEnvironment || _torrentX == false)
|
||||||
{
|
{
|
||||||
@@ -914,7 +914,7 @@ namespace SabreTools.Helper
|
|||||||
// Then add each of the found files to the new dictionary
|
// Then add each of the found files to the new dictionary
|
||||||
foreach (Rom rom in roms)
|
foreach (Rom rom in roms)
|
||||||
{
|
{
|
||||||
string key = rom.HashData.Size + "-" + rom.HashData.CRC;
|
string key = rom.Size + "-" + rom.CRC;
|
||||||
if (scanned.ContainsKey(key))
|
if (scanned.ContainsKey(key))
|
||||||
{
|
{
|
||||||
scanned[key].Add(rom);
|
scanned[key].Add(rom);
|
||||||
|
|||||||
@@ -122,10 +122,10 @@ Please check the log folder if the stats scrolled offscreen");
|
|||||||
{
|
{
|
||||||
datdata.RomCount += (rom.Type == ItemType.Rom ? 1 : 0);
|
datdata.RomCount += (rom.Type == ItemType.Rom ? 1 : 0);
|
||||||
datdata.DiskCount += (rom.Type == ItemType.Disk ? 1 : 0);
|
datdata.DiskCount += (rom.Type == ItemType.Disk ? 1 : 0);
|
||||||
datdata.TotalSize += (rom.Nodump ? 0 : rom.HashData.Size);
|
datdata.TotalSize += (rom.Nodump ? 0 : rom.Size);
|
||||||
datdata.CRCCount += (String.IsNullOrEmpty(rom.HashData.CRC) ? 0 : 1);
|
datdata.CRCCount += (String.IsNullOrEmpty(rom.CRC) ? 0 : 1);
|
||||||
datdata.MD5Count += (String.IsNullOrEmpty(rom.HashData.MD5) ? 0 : 1);
|
datdata.MD5Count += (String.IsNullOrEmpty(rom.MD5) ? 0 : 1);
|
||||||
datdata.SHA1Count += (String.IsNullOrEmpty(rom.HashData.SHA1) ? 0 : 1);
|
datdata.SHA1Count += (String.IsNullOrEmpty(rom.SHA1) ? 0 : 1);
|
||||||
datdata.NodumpCount += (rom.Nodump ? 1 : 0);
|
datdata.NodumpCount += (rom.Nodump ? 1 : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ namespace SabreTools.Helper
|
|||||||
writeStream.Write(buffer, 0, len);
|
writeStream.Write(buffer, 0, len);
|
||||||
}
|
}
|
||||||
writeStream.Flush();
|
writeStream.Flush();
|
||||||
zipFile.CloseWriteStream(Convert.ToUInt32(rom.HashData.CRC, 16));
|
zipFile.CloseWriteStream(Convert.ToUInt32(rom.CRC, 16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,7 +291,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
freadStream.Close();
|
freadStream.Close();
|
||||||
freadStream.Dispose();
|
freadStream.Dispose();
|
||||||
zipFile.CloseWriteStream(Convert.ToUInt32(roms[-index - 1].HashData.CRC, 16));
|
zipFile.CloseWriteStream(Convert.ToUInt32(roms[-index - 1].CRC, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, copy the file from the old archive
|
// Otherwise, copy the file from the old archive
|
||||||
@@ -372,7 +372,7 @@ namespace SabreTools.Helper
|
|||||||
Rom rom = FileTools.GetSingleFileInfo(input);
|
Rom rom = FileTools.GetSingleFileInfo(input);
|
||||||
|
|
||||||
// If it doesn't exist, create the output file and then write
|
// If it doesn't exist, create the output file and then write
|
||||||
string outfile = Path.Combine(outDir, rom.HashData.SHA1 + ".gz");
|
string outfile = Path.Combine(outDir, rom.SHA1 + ".gz");
|
||||||
using (FileStream inputstream = new FileStream(input, FileMode.Open))
|
using (FileStream inputstream = new FileStream(input, FileMode.Open))
|
||||||
using (GZipStream output = new GZipStream(File.Open(outfile, FileMode.Create, FileAccess.Write), CompressionMode.Compress))
|
using (GZipStream output = new GZipStream(File.Open(outfile, FileMode.Create, FileAccess.Write), CompressionMode.Compress))
|
||||||
{
|
{
|
||||||
@@ -386,9 +386,9 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
// Write standard header and TGZ info
|
// Write standard header and TGZ info
|
||||||
byte[] data = Constants.TorrentGZHeader
|
byte[] data = Constants.TorrentGZHeader
|
||||||
.Concat(Style.StringToByteArray(rom.HashData.MD5)) // MD5
|
.Concat(Style.StringToByteArray(rom.MD5)) // MD5
|
||||||
.Concat(Style.StringToByteArray(rom.HashData.CRC)) // CRC
|
.Concat(Style.StringToByteArray(rom.CRC)) // CRC
|
||||||
.Concat(BitConverter.GetBytes(rom.HashData.Size).Reverse().ToArray()) // Long size (Mirrored)
|
.Concat(BitConverter.GetBytes(rom.Size).Reverse().ToArray()) // Long size (Mirrored)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
sw.Write(data);
|
sw.Write(data);
|
||||||
|
|
||||||
@@ -414,7 +414,7 @@ namespace SabreTools.Helper
|
|||||||
// If we're in romba mode, create the subfolder and move the file
|
// If we're in romba mode, create the subfolder and move the file
|
||||||
if (romba)
|
if (romba)
|
||||||
{
|
{
|
||||||
string subfolder = Path.Combine(rom.HashData.SHA1.Substring(0, 2), rom.HashData.SHA1.Substring(2, 2), rom.HashData.SHA1.Substring(4, 2), rom.HashData.SHA1.Substring(6, 2));
|
string subfolder = Path.Combine(rom.SHA1.Substring(0, 2), rom.SHA1.Substring(2, 2), rom.SHA1.Substring(4, 2), rom.SHA1.Substring(6, 2));
|
||||||
outDir = Path.Combine(outDir, subfolder);
|
outDir = Path.Combine(outDir, subfolder);
|
||||||
if (!Directory.Exists(outDir))
|
if (!Directory.Exists(outDir))
|
||||||
{
|
{
|
||||||
@@ -723,13 +723,10 @@ namespace SabreTools.Helper
|
|||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Type = ItemType.Rom,
|
Type = ItemType.Rom,
|
||||||
HashData = new Hash
|
|
||||||
{
|
|
||||||
Size = input.Length - Math.Abs(offset),
|
Size = input.Length - Math.Abs(offset),
|
||||||
CRC = string.Empty,
|
CRC = string.Empty,
|
||||||
MD5 = string.Empty,
|
MD5 = string.Empty,
|
||||||
SHA1 = string.Empty,
|
SHA1 = string.Empty,
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -760,21 +757,18 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
crc.Update(buffer, 0, 0);
|
crc.Update(buffer, 0, 0);
|
||||||
Hash tempHash = new Hash();
|
rom.CRC = crc.Value.ToString("X8").ToLowerInvariant();
|
||||||
tempHash.CRC = crc.Value.ToString("X8").ToLowerInvariant();
|
|
||||||
|
|
||||||
if (!noMD5)
|
if (!noMD5)
|
||||||
{
|
{
|
||||||
md5.TransformFinalBlock(buffer, 0, 0);
|
md5.TransformFinalBlock(buffer, 0, 0);
|
||||||
tempHash.MD5 = BitConverter.ToString(md5.Hash).Replace("-", "").ToLowerInvariant();
|
rom.MD5 = BitConverter.ToString(md5.Hash).Replace("-", "").ToLowerInvariant();
|
||||||
}
|
}
|
||||||
if (!noSHA1)
|
if (!noSHA1)
|
||||||
{
|
{
|
||||||
sha1.TransformFinalBlock(buffer, 0, 0);
|
sha1.TransformFinalBlock(buffer, 0, 0);
|
||||||
tempHash.SHA1 = BitConverter.ToString(sha1.Hash).Replace("-", "").ToLowerInvariant();
|
rom.SHA1 = BitConverter.ToString(sha1.Hash).Replace("-", "").ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
rom.HashData = tempHash;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException)
|
catch (IOException)
|
||||||
@@ -864,11 +858,8 @@ namespace SabreTools.Helper
|
|||||||
Type = ItemType.Rom,
|
Type = ItemType.Rom,
|
||||||
Name = reader.Entry.Key,
|
Name = reader.Entry.Key,
|
||||||
MachineName = gamename,
|
MachineName = gamename,
|
||||||
HashData = new Hash
|
|
||||||
{
|
|
||||||
Size = (size == 0 ? reader.Entry.Size : size),
|
Size = (size == 0 ? reader.Entry.Size : size),
|
||||||
CRC = (crc == "" ? reader.Entry.Crc.ToString("X").ToLowerInvariant() : crc),
|
CRC = (crc == "" ? reader.Entry.Crc.ToString("X").ToLowerInvariant() : crc),
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -950,13 +941,10 @@ namespace SabreTools.Helper
|
|||||||
Type = ItemType.Rom,
|
Type = ItemType.Rom,
|
||||||
MachineName = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
MachineName = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
||||||
Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
||||||
HashData = new Hash
|
|
||||||
{
|
|
||||||
Size = extractedsize,
|
Size = extractedsize,
|
||||||
CRC = gzcrc.ToLowerInvariant(),
|
CRC = gzcrc.ToLowerInvariant(),
|
||||||
MD5 = gzmd5.ToLowerInvariant(),
|
MD5 = gzmd5.ToLowerInvariant(),
|
||||||
SHA1 = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
SHA1 = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return rom;
|
return rom;
|
||||||
|
|||||||
Reference in New Issue
Block a user