Revert "[ALL] Fix String.Empty"

This reverts commit c02a115c98.
This commit is contained in:
Matt Nadareski
2017-01-27 16:53:23 -08:00
parent e3daf4ce69
commit c8142549bb
15 changed files with 294 additions and 379 deletions

View File

@@ -87,7 +87,7 @@ namespace SabreTools
dbc.Open();
StreamWriter sw = new StreamWriter(File.Open("export.csv", FileMode.Create, FileAccess.Write));
sw.WriteLine("\"ID\",\"Size\",\"CRC\",\"MD5\",\"SHA-1\",\"In Depot\",\"DAT Hash\"");
sw.WriteLine("\"ID\",\"Size\",\"CRC\",\"MD5\",\"SHA-1\",\"In Depot\",\"DAT Hash"");
string query = "SELECT dats.id, size, crc, md5, sha1, indepot, hash FROM data JOIN dats ON data.id=dats.id";
SqliteCommand slc = new SqliteCommand(query, dbc);
@@ -97,13 +97,13 @@ namespace SabreTools
{
while (sldr.Read())
{
string line = "\"" + sldr.GetInt32(0) + "\","
+ "\"" + sldr.GetInt64(1) + "\","
+ "\"" + sldr.GetString(2) + "\","
+ "\"" + sldr.GetString(3) + "\","
+ "\"" + sldr.GetString(4) + "\","
+ "\"" + sldr.GetInt32(5) + "\","
+ "\"" + sldr.GetString(6) + "\"";
string line = """ + sldr.GetInt32(0) + "\","
+ """ + sldr.GetInt64(1) + "\","
+ """ + sldr.GetString(2) + "\","
+ """ + sldr.GetString(3) + "\","
+ """ + sldr.GetString(4) + "\","
+ """ + sldr.GetInt32(5) + "\","
+ """ + sldr.GetString(6) + """;
sw.WriteLine(line);
}
}
@@ -459,7 +459,7 @@ namespace SabreTools
foreach (string dathash in unneeded)
{
query = "DELETE FROM dats WHERE hash=\"" + dathash + "\"";
query = "DELETE FROM dats WHERE hash="" + dathash + """;
slc = new SqliteCommand(query, dbc);
slc.ExecuteNonQuery();
slc.Dispose();
@@ -502,23 +502,23 @@ namespace SabreTools
if (!String.IsNullOrEmpty(rom.CRC))
{
crcquery += " (\"" + rom.CRC + "\"),";
crcquery += " ("" + rom.CRC + "\"),";
}
if (!String.IsNullOrEmpty(rom.MD5))
{
md5query += " (\"" + rom.MD5 + "\"),";
md5query += " ("" + rom.MD5 + "\"),";
}
if (!String.IsNullOrEmpty(rom.SHA1))
{
sha1query += " (\"" + rom.SHA1 + "\"),";
sha1query += " ("" + rom.SHA1 + "\"),";
if (!String.IsNullOrEmpty(rom.CRC))
{
crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),";
crcsha1query += " ("" + rom.CRC + "\", "" + rom.SHA1 + "\"),";
}
if (!String.IsNullOrEmpty(rom.MD5))
{
md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),";
md5sha1query += " ("" + rom.MD5 + "\", "" + rom.SHA1 + "\"),";
}
}
}
@@ -528,15 +528,15 @@ namespace SabreTools
if (!String.IsNullOrEmpty(disk.MD5))
{
md5query += " (\"" + disk.MD5 + "\"),";
md5query += " ("" + disk.MD5 + "\"),";
}
if (!String.IsNullOrEmpty(disk.SHA1))
{
sha1query += " (\"" + disk.SHA1 + "\"),";
sha1query += " ("" + disk.SHA1 + "\"),";
if (!String.IsNullOrEmpty(disk.MD5))
{
md5sha1query += " (\"" + disk.MD5 + "\", \"" + disk.SHA1 + "\"),";
md5sha1query += " ("" + disk.MD5 + "\", "" + disk.SHA1 + "\"),";
}
}
}
@@ -571,7 +571,7 @@ namespace SabreTools
}
}
string datquery = "INSERT OR IGNORE INTO dat (hash) VALUES (\"" + dat.SHA1 + "\")";
string datquery = "INSERT OR IGNORE INTO dat (hash) VALUES ("" + dat.SHA1 + "\")";
slc = new SqliteCommand(datquery, dbc);
slc.ExecuteNonQuery();
slc.Dispose();
@@ -603,7 +603,7 @@ namespace SabreTools
// If we have it, then check for all hashes that are in that depot
List<string> hashes = new List<string>();
string query = "SELECT sha1 FROM sha1 WHERE depot=\"" + depotname + "\"";
string query = "SELECT sha1 FROM sha1 WHERE depot="" + depotname + """;
SqliteCommand slc = new SqliteCommand(query, dbc);
SqliteDataReader sldr = slc.ExecuteReader();
if (sldr.HasRows)
@@ -643,23 +643,23 @@ namespace SabreTools
{
if (!String.IsNullOrEmpty(rom.CRC))
{
crcquery += " (\"" + rom.CRC + "\"),";
crcquery += " ("" + rom.CRC + "\"),";
}
if (!String.IsNullOrEmpty(rom.MD5))
{
md5query += " (\"" + rom.MD5 + "\"),";
md5query += " ("" + rom.MD5 + "\"),";
}
if (!String.IsNullOrEmpty(rom.SHA1))
{
sha1query += " (\"" + rom.SHA1 + "\", \"" + depotname + "\"),";
sha1query += " ("" + rom.SHA1 + "\", "" + depotname + "\"),";
if (!String.IsNullOrEmpty(rom.CRC))
{
crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),";
crcsha1query += " ("" + rom.CRC + "\", "" + rom.SHA1 + "\"),";
}
if (!String.IsNullOrEmpty(rom.MD5))
{
md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),";
md5sha1query += " ("" + rom.MD5 + "\", "" + rom.SHA1 + "\"),";
}
}
}
@@ -703,7 +703,7 @@ JOIN crc
ON crcsha1.crc=crc.crc
JOIN md5
ON md5sha1.md5=md5.md5
WHERE sha1.sha1 IN (String.Empty" + String.Join("\",\"", hashes) + "\")";
WHERE sha1.sha1 IN (String.Empty" + String.Join("\","", hashes) + "\")";
slc = new SqliteCommand(query, dbc);
slc.ExecuteNonQuery();

View File

@@ -73,9 +73,9 @@ namespace SabreTools
if (onlyNeeded)
{
string query = "SELECT * FROM crcsha1 JOIN md5sha1 ON crcsha1.sha1=md5sha1.sha1"
+ " WHERE crcsha1.crc=\"" + rom.CRC + "\""
+ " OR md5sha1.md5=\"" + rom.MD5 + "\""
+ " OR md5sha1.sha1=\"" + rom.SHA1 + "\"";
+ " WHERE crcsha1.crc="" + rom.CRC + """
+ " OR md5sha1.md5="" + rom.MD5 + """
+ " OR md5sha1.sha1="" + rom.SHA1 + """;
SqliteCommand slc = new SqliteCommand(query, dbc);
SqliteDataReader sldr = slc.ExecuteReader();
@@ -84,23 +84,23 @@ namespace SabreTools
// Add to the queries
if (!String.IsNullOrEmpty(rom.CRC))
{
crcquery += " (\"" + rom.CRC + "\"),";
crcquery += " ("" + rom.CRC + "\"),";
}
if (!String.IsNullOrEmpty(rom.MD5))
{
md5query += " (\"" + rom.MD5 + "\"),";
md5query += " ("" + rom.MD5 + "\"),";
}
if (!String.IsNullOrEmpty(rom.SHA1))
{
sha1query += " (\"" + rom.SHA1 + "\", \"" + _depots.Keys.ToList()[0] + "\"),";
sha1query += " ("" + rom.SHA1 + "\", "" + _depots.Keys.ToList()[0] + "\"),";
if (!String.IsNullOrEmpty(rom.CRC))
{
crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),";
crcsha1query += " ("" + rom.CRC + "\", "" + rom.SHA1 + "\"),";
}
if (!String.IsNullOrEmpty(rom.MD5))
{
md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),";
md5sha1query += " ("" + rom.MD5 + "\", "" + rom.SHA1 + "\"),";
}
}
@@ -114,23 +114,23 @@ namespace SabreTools
// Add to the queries
if (!String.IsNullOrEmpty(rom.CRC))
{
crcquery += " (\"" + rom.CRC + "\"),";
crcquery += " ("" + rom.CRC + "\"),";
}
if (!String.IsNullOrEmpty(rom.MD5))
{
md5query += " (\"" + rom.MD5 + "\"),";
md5query += " ("" + rom.MD5 + "\"),";
}
if (!String.IsNullOrEmpty(rom.SHA1))
{
sha1query += " (\"" + rom.SHA1 + "\", \"" + _depots.Keys.ToList()[0] + "\"),";
sha1query += " ("" + rom.SHA1 + "\", "" + _depots.Keys.ToList()[0] + "\"),";
if (!String.IsNullOrEmpty(rom.CRC))
{
crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),";
crcsha1query += " ("" + rom.CRC + "\", "" + rom.SHA1 + "\"),";
}
if (!String.IsNullOrEmpty(rom.MD5))
{
md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),";
md5sha1query += " ("" + rom.MD5 + "\", "" + rom.SHA1 + "\"),";
}
}
@@ -320,7 +320,7 @@ namespace SabreTools
// Now, search for each of them and return true or false for each
foreach (string input in crc)
{
string query = "SELECT * FROM crc WHERE crc=\"" + input + "\"";
string query = "SELECT * FROM crc WHERE crc="" + input + """;
SqliteCommand slc = new SqliteCommand(query, dbc);
SqliteDataReader sldr = slc.ExecuteReader();
if (sldr.HasRows)
@@ -337,7 +337,7 @@ namespace SabreTools
}
foreach (string input in md5)
{
string query = "SELECT * FROM md5 WHERE md5=\"" + input + "\"";
string query = "SELECT * FROM md5 WHERE md5="" + input + """;
SqliteCommand slc = new SqliteCommand(query, dbc);
SqliteDataReader sldr = slc.ExecuteReader();
if (sldr.HasRows)
@@ -354,7 +354,7 @@ namespace SabreTools
}
foreach (string input in sha1)
{
string query = "SELECT * FROM sha1 WHERE sha1=\"" + input + "\"";
string query = "SELECT * FROM sha1 WHERE sha1="" + input + """;
SqliteCommand slc = new SqliteCommand(query, dbc);
SqliteDataReader sldr = slc.ExecuteReader();
if (sldr.HasRows)

View File

@@ -6,13 +6,13 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RombaSharp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyDescription(String.Empty)]
[assembly: AssemblyConfiguration(String.Empty)]
[assembly: AssemblyCompany(String.Empty)]
[assembly: AssemblyProduct("RombaSharp")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyTrademark(String.Empty)]
[assembly: AssemblyCulture(String.Empty)]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from

View File

@@ -178,7 +178,7 @@ namespace SabreTools
outdat = args[i];
break;
default:
string temparg = args[i].Replace("\"", String.Empty).Replace("file://", String.Empty);
string temparg = args[i].Replace(""", String.Empty).Replace("file://", String.Empty);
if (temparg.StartsWith("-") && temparg.Contains("="))
{

View File

@@ -478,7 +478,7 @@ namespace SabreTools.Helper.Dats
if (File.Exists(inputFileName))
{
DatFile innerDatdata = new DatFile(this);
logger.User("Processing \"" + Path.GetFileName(inputFileName) + "\"");
logger.User("Processing "" + Path.GetFileName(inputFileName) + """);
innerDatdata.Parse(inputFileName, 0, 0, filter, splitType, trim, single,
root, logger, true, clean, softlist,
keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0));
@@ -497,7 +497,7 @@ namespace SabreTools.Helper.Dats
new ParallelOptions { MaxDegreeOfParallelism = maxDegreeOfParallelism },
file =>
{
logger.User("Processing \"" + Path.GetFullPath(file).Remove(0, inputFileName.Length) + "\"");
logger.User("Processing "" + Path.GetFullPath(file).Remove(0, inputFileName.Length) + """);
DatFile innerDatdata = new DatFile(this);
innerDatdata.Parse(file, 0, 0, filter, splitType,
trim, single, root, logger, true, clean, softlist,

View File

@@ -369,7 +369,7 @@ namespace SabreTools.Helper.Dats
// If we have a sample, treat it special
if (temptype == ItemType.Sample)
{
line = line.Trim().Remove(0, 6).Trim().Replace("\"", String.Empty); // Remove "sample" from the input string
line = line.Trim().Remove(0, 6).Trim().Replace(""", String.Empty); // Remove "sample" from the input string
item.Name = line;
// Now process and add the sample
@@ -421,7 +421,7 @@ namespace SabreTools.Helper.Dats
else if (gc[i] == "date")
{
i++;
((Rom)item).Date = gc[i].Replace("\"", String.Empty) + " " + gc[i + 1].Replace("\"", String.Empty);
((Rom)item).Date = gc[i].Replace(""", String.Empty) + " " + gc[i + 1].Replace(""", String.Empty);
i += 3;
}
@@ -429,7 +429,7 @@ namespace SabreTools.Helper.Dats
else if (gc[i] == "crc")
{
i++;
((Rom)item).CRC = gc[i].Replace("\"", String.Empty).ToLowerInvariant();
((Rom)item).CRC = gc[i].Replace(""", String.Empty).ToLowerInvariant();
}
}
@@ -443,11 +443,11 @@ namespace SabreTools.Helper.Dats
for (int i = 0; i < gc.Length; i++)
{
// Look at the current item and use it if possible
string quoteless = gc[i].Replace("\"", String.Empty);
string quoteless = gc[i].Replace(""", String.Empty);
switch (quoteless)
{
//If the item is empty, we automatically skip it because it's a fluke
case "":
case String.Empty:
continue;
// Special cases for standalone item statuses
@@ -495,14 +495,14 @@ namespace SabreTools.Helper.Dats
// Regular attributes
case "name":
i++;
quoteless = gc[i].Replace("\"", String.Empty);
quoteless = gc[i].Replace(""", String.Empty);
item.Name = quoteless;
break;
case "size":
if (item.Type == ItemType.Rom)
{
i++;
quoteless = gc[i].Replace("\"", String.Empty);
quoteless = gc[i].Replace(""", String.Empty);
long size = -1;
if (Int64.TryParse(quoteless, out size))
{
@@ -515,7 +515,7 @@ namespace SabreTools.Helper.Dats
if (item.Type == ItemType.Rom)
{
i++;
quoteless = gc[i].Replace("\"", String.Empty);
quoteless = gc[i].Replace(""", String.Empty);
((Rom)item).CRC = quoteless.ToLowerInvariant();
}
break;
@@ -523,13 +523,13 @@ namespace SabreTools.Helper.Dats
if (item.Type == ItemType.Rom)
{
i++;
quoteless = gc[i].Replace("\"", String.Empty);
quoteless = gc[i].Replace(""", String.Empty);
((Rom)item).MD5 = quoteless.ToLowerInvariant();
}
else if (item.Type == ItemType.Disk)
{
i++;
quoteless = gc[i].Replace("\"", String.Empty);
quoteless = gc[i].Replace(""", String.Empty);
((Disk)item).MD5 = quoteless.ToLowerInvariant();
}
break;
@@ -537,20 +537,20 @@ namespace SabreTools.Helper.Dats
if (item.Type == ItemType.Rom)
{
i++;
quoteless = gc[i].Replace("\"", String.Empty);
quoteless = gc[i].Replace(""", String.Empty);
((Rom)item).SHA1 = quoteless.ToLowerInvariant();
}
else if (item.Type == ItemType.Disk)
{
i++;
quoteless = gc[i].Replace("\"", String.Empty);
quoteless = gc[i].Replace(""", String.Empty);
((Disk)item).SHA1 = quoteless.ToLowerInvariant();
}
break;
case "status":
case "flags":
i++;
quoteless = gc[i].Replace("\"", String.Empty);
quoteless = gc[i].Replace(""", String.Empty);
if (quoteless.ToLowerInvariant() == "good")
{
if (item.Type == ItemType.Rom)
@@ -600,7 +600,7 @@ namespace SabreTools.Helper.Dats
if (item.Type == ItemType.Rom)
{
i++;
quoteless = gc[i].Replace("\"", String.Empty) + " " + gc[i + 1].Replace("\"", String.Empty);
quoteless = gc[i].Replace(""", String.Empty) + " " + gc[i + 1].Replace(""", String.Empty);
((Rom)item).Date = quoteless;
}
i++;
@@ -620,7 +620,7 @@ namespace SabreTools.Helper.Dats
if (blockname != "header")
{
string itemval = gc[2].Value.Replace("\"", String.Empty);
string itemval = gc[2].Value.Replace(""", String.Empty);
switch (gc[1].Value)
{
case "name":
@@ -648,7 +648,7 @@ namespace SabreTools.Helper.Dats
}
else
{
string itemval = gc[2].Value.Replace("\"", String.Empty);
string itemval = gc[2].Value.Replace(""", String.Empty);
if (line.Trim().StartsWith("Name:"))
{
@@ -1418,7 +1418,7 @@ namespace SabreTools.Helper.Dats
machine.Description = subreader.ReadElementContentAsString();
if (!softlist && temptype == "software")
{
machine.Name = machine.Description.Replace('/', '_').Replace("\"", "''");
machine.Name = machine.Description.Replace('/', '_').Replace(""", "''");
}
break;
case "year":
@@ -1580,13 +1580,13 @@ namespace SabreTools.Helper.Dats
if (subreader.GetAttribute("flags") == "baddump" || subreader.GetAttribute("status") == "baddump")
{
logger.Verbose("Bad dump detected: " +
(subreader.GetAttribute("name") != null && subreader.GetAttribute("name") != String.Empty ? "\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
(subreader.GetAttribute("name") != null && subreader.GetAttribute("name") != String.Empty ? """ + xtr.GetAttribute("name") + """ : "ROM NAME NOT FOUND"));
its = ItemStatus.BadDump;
}
if (subreader.GetAttribute("flags") == "nodump" || subreader.GetAttribute("status") == "nodump")
{
logger.Verbose("Nodump detected: " +
(subreader.GetAttribute("name") != null && subreader.GetAttribute("name") != String.Empty ? "\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
(subreader.GetAttribute("name") != null && subreader.GetAttribute("name") != String.Empty ? """ + xtr.GetAttribute("name") + """ : "ROM NAME NOT FOUND"));
its = ItemStatus.Nodump;
}
if (subreader.GetAttribute("flags") == "verified" || subreader.GetAttribute("status") == "verified")
@@ -1765,12 +1765,12 @@ namespace SabreTools.Helper.Dats
break;
case "baddump":
logger.Verbose("Bad dump detected: " + (xtr.GetAttribute("name") != null && xtr.GetAttribute("name") != String.Empty ?
"\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
""" + xtr.GetAttribute("name") + """ : "ROM NAME NOT FOUND"));
its = ItemStatus.BadDump;
break;
case "nodump":
logger.Verbose("Nodump detected: " + (xtr.GetAttribute("name") != null && xtr.GetAttribute("name") != String.Empty ?
"\"" + xtr.GetAttribute("name") + "\"" : "ROM NAME NOT FOUND"));
""" + xtr.GetAttribute("name") + """ : "ROM NAME NOT FOUND"));
its = ItemStatus.Nodump;
break;
case "verified":
@@ -2304,7 +2304,7 @@ namespace SabreTools.Helper.Dats
// If the file has no size and it's not the above case, skip and log
else if (itemRom.ItemStatus != ItemStatus.Nodump && (itemRom.Size == 0 || itemRom.Size == -1))
{
logger.Verbose("Incomplete entry for \"" + itemRom.Name + "\" will be output as nodump");
logger.Verbose("Incomplete entry for "" + itemRom.Name + "\" will be output as nodump");
itemRom.ItemStatus = ItemStatus.Nodump;
}
// If the file has a size but aboslutely no hashes, skip and log
@@ -2314,7 +2314,7 @@ namespace SabreTools.Helper.Dats
&& String.IsNullOrEmpty(itemRom.MD5)
&& String.IsNullOrEmpty(itemRom.SHA1))
{
logger.Verbose("Incomplete entry for \"" + itemRom.Name + "\" will be output as nodump");
logger.Verbose("Incomplete entry for "" + itemRom.Name + "\" will be output as nodump");
itemRom.ItemStatus = ItemStatus.Nodump;
}
@@ -2333,7 +2333,7 @@ namespace SabreTools.Helper.Dats
&& String.IsNullOrEmpty(itemDisk.MD5)
&& String.IsNullOrEmpty(itemDisk.SHA1))
{
logger.Verbose("Incomplete entry for \"" + itemDisk.Name + "\" will be output as nodump");
logger.Verbose("Incomplete entry for "" + itemDisk.Name + "\" will be output as nodump");
itemDisk.ItemStatus = ItemStatus.Nodump;
}

View File

@@ -158,22 +158,22 @@ namespace SabreTools.Helper.Dats
}
if (outputs.ContainsKey(StatDatFormat.CSV))
{
line = "\"" + FileName + "\","
+ "\"" + TotalSize + "\","
+ "\"" + (game == -1 ? Count : game) + "\","
+ "\"" + RomCount + "\","
+ "\"" + DiskCount + "\","
+ "\"" + CRCCount + "\","
+ "\"" + MD5Count + "\","
+ "\"" + SHA1Count + "\"";
line = """ + FileName + "\","
+ """ + TotalSize + "\","
+ """ + (game == -1 ? Count : game) + "\","
+ """ + RomCount + "\","
+ """ + DiskCount + "\","
+ """ + CRCCount + "\","
+ """ + MD5Count + "\","
+ """ + SHA1Count + """;
if (baddumpCol)
{
line += ",\"" + BaddumpCount + "\"";
line += ","" + BaddumpCount + """;
}
if (nodumpCol)
{
line += ",\"" + NodumpCount + "\"";
line += ","" + NodumpCount + """;
}
line += "\n";
@@ -206,22 +206,22 @@ namespace SabreTools.Helper.Dats
}
if (outputs.ContainsKey(StatDatFormat.TSV))
{
line = "\"" + FileName + "\"\t"
+ "\"" + TotalSize + "\"\t"
+ "\"" + (game == -1 ? Count : game) + "\"\t"
+ "\"" + RomCount + "\"\t"
+ "\"" + DiskCount + "\"\t"
+ "\"" + CRCCount + "\"\t"
+ "\"" + MD5Count + "\"\t"
+ "\"" + SHA1Count + "\"";
line = """ + FileName + "\"\t"
+ """ + TotalSize + "\"\t"
+ """ + (game == -1 ? Count : game) + "\"\t"
+ """ + RomCount + "\"\t"
+ """ + DiskCount + "\"\t"
+ """ + CRCCount + "\"\t"
+ """ + MD5Count + "\"\t"
+ """ + SHA1Count + """;
if (baddumpCol)
{
line += "\t\"" + BaddumpCount + "\"";
line += "\t"" + BaddumpCount + """;
}
if (nodumpCol)
{
line += "\t\"" + NodumpCount + "\"";
line += "\t"" + NodumpCount + """;
}
line += "\n";
@@ -530,8 +530,8 @@ Please check the log folder if the stats scrolled offscreen", false);
}
if (outputs.ContainsKey(StatDatFormat.CSV))
{
outputs[StatDatFormat.CSV].Write("\"File Name\",\"Total Size\",\"Games\",\"Roms\",\"Disks\",\"# with CRC\",\"# with MD5\",\"# with SHA-1\""
+ (baddumpCol ? ",\"BadDumps\"" : String.Empty) + (nodumpCol ? ",\"Nodumps\"" : String.Empty) + "\n");
outputs[StatDatFormat.CSV].Write("\"File Name\",\"Total Size\",\"Games\",\"Roms\",\"Disks\",\"# with CRC\",\"# with MD5\",\"# with SHA-1""
+ (baddumpCol ? ",\"BadDumps"" : String.Empty) + (nodumpCol ? ",\"Nodumps"" : String.Empty) + "\n");
}
if (outputs.ContainsKey(StatDatFormat.HTML))
{
@@ -558,8 +558,8 @@ Please check the log folder if the stats scrolled offscreen", false);
}
if (outputs.ContainsKey(StatDatFormat.TSV))
{
outputs[StatDatFormat.TSV].Write("\"File Name\"\t\"Total Size\"\t\"Games\"\t\"Roms\"\t\"Disks\"\t\"# with CRC\"\t\"# with MD5\"\t\"# with SHA-1\""
+ (baddumpCol ? "\t\"BadDumps\"" : String.Empty) + (nodumpCol ? "\t\"Nodumps\"" : String.Empty) + "\n");
outputs[StatDatFormat.TSV].Write("\"File Name\"\t\"Total Size\"\t\"Games\"\t\"Roms\"\t\"Disks\"\t\"# with CRC\"\t\"# with MD5\"\t\"# with SHA-1""
+ (baddumpCol ? "\t\"BadDumps"" : String.Empty) + (nodumpCol ? "\t\"Nodumps"" : String.Empty) + "\n");
}
// Now write the mid header for those who need it
@@ -614,7 +614,7 @@ Please check the log folder if the stats scrolled offscreen", false);
}
if (outputs.ContainsKey(StatDatFormat.HTML))
{
outputs[StatDatFormat.HTML].Write("<tr><td colspan=\""
outputs[StatDatFormat.HTML].Write("<tr><td colspan=""
+ (baddumpCol && nodumpCol
? "11"
: (baddumpCol ^ nodumpCol
@@ -648,7 +648,7 @@ Please check the log folder if the stats scrolled offscreen", false);
}
if (outputs.ContainsKey(StatDatFormat.HTML))
{
outputs[StatDatFormat.HTML].Write("<tr border=\"0\"><td colspan=\""
outputs[StatDatFormat.HTML].Write("<tr border=\"0\"><td colspan=""
+ (baddumpCol && nodumpCol
? "11"
: (baddumpCol ^ nodumpCol

View File

@@ -1,171 +1,171 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SabreTools.Helper.Resources {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SabreTools.Helper.Resources.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to This is the default help output.
/// </summary>
public static string Default_Desc {
get {
return ResourceManager.GetString("Default_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Remove and restore rom headers.
/// </summary>
public static string Headerer_Desc {
get {
return ResourceManager.GetString("Headerer_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Headerer.
/// </summary>
public static string Headerer_Name {
get {
return ResourceManager.GetString("Headerer_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to C# port of the Romba rom management tool.
/// </summary>
public static string RombaSharp_Desc {
get {
return ResourceManager.GetString("RombaSharp_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to RombaSharp.
/// </summary>
public static string RombaSharp_Name {
get {
return ResourceManager.GetString("RombaSharp_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Import, generate, manipulate DAT files.
/// </summary>
public static string SabreTools_Desc {
get {
return ResourceManager.GetString("SabreTools_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to SabreTools.
/// </summary>
public static string SabreTools_Name {
get {
return ResourceManager.GetString("SabreTools_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Basic rebuild using a DAT.
/// </summary>
public static string SimpleSort_Desc {
get {
return ResourceManager.GetString("SimpleSort_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to SimpleSort.
/// </summary>
public static string SimpleSort_Name {
get {
return ResourceManager.GetString("SimpleSort_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Convert files to TGZ output.
/// </summary>
public static string TGZTest_Desc {
get {
return ResourceManager.GetString("TGZTest_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to TGZConvert.
/// </summary>
public static string TGZTest_Name {
get {
return ResourceManager.GetString("TGZTest_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Usage.
/// </summary>
public static string Usage {
get {
return ResourceManager.GetString("Usage", resourceCulture);
}
}
}
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SabreTools.Helper.Resources.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to This is the default help output.
/// </summary>
public static string Default_Desc {
get {
return ResourceManager.GetString("Default_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Remove and restore rom headers.
/// </summary>
public static string Headerer_Desc {
get {
return ResourceManager.GetString("Headerer_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Headerer.
/// </summary>
public static string Headerer_Name {
get {
return ResourceManager.GetString("Headerer_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to C# port of the Romba rom management tool.
/// </summary>
public static string RombaSharp_Desc {
get {
return ResourceManager.GetString("RombaSharp_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to RombaSharp.
/// </summary>
public static string RombaSharp_Name {
get {
return ResourceManager.GetString("RombaSharp_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Import, generate, manipulate DAT files.
/// </summary>
public static string SabreTools_Desc {
get {
return ResourceManager.GetString("SabreTools_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to SabreTools.
/// </summary>
public static string SabreTools_Name {
get {
return ResourceManager.GetString("SabreTools_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Basic rebuild using a DAT.
/// </summary>
public static string SimpleSort_Desc {
get {
return ResourceManager.GetString("SimpleSort_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to SimpleSort.
/// </summary>
public static string SimpleSort_Name {
get {
return ResourceManager.GetString("SimpleSort_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Convert files to TGZ output.
/// </summary>
public static string TGZTest_Desc {
get {
return ResourceManager.GetString("TGZTest_Desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to TGZConvert.
/// </summary>
public static string TGZTest_Name {
get {
return ResourceManager.GetString("TGZTest_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Usage.
/// </summary>
public static string Usage {
get {
return ResourceManager.GetString("Usage", resourceCulture);
}
}
}
}

View File

@@ -59,7 +59,7 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:schema id="root" xmlns=String.Empty xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>

View File

@@ -59,7 +59,7 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:schema id="root" xmlns=String.Empty xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>

View File

@@ -59,7 +59,7 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:schema id="root" xmlns=String.Empty xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>

View File

@@ -59,7 +59,7 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:schema id="root" xmlns=String.Empty xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>

View File

@@ -1102,13 +1102,6 @@ namespace SabreTools.Helper.Tools
public static bool WriteTAR(List<string> inputFiles, string outDir, List<Rom> roms, Logger logger, bool date = false)
{
bool success = false;
string tempFile = Path.GetTempFileName();
// If either list of roms is null or empty, return
if (inputFiles == null || roms == null || inputFiles.Count == 0 || roms.Count == 0)
{
return success;
}
// If the number of inputs is less than the number of available roms, return
if (inputFiles.Count < roms.Count)
@@ -1129,8 +1122,8 @@ namespace SabreTools.Helper.Tools
string archiveFileName = Path.Combine(outDir, Style.RemovePathUnsafeCharacters(roms[0].Machine.Name) + (roms[0].Machine.Name.EndsWith(".tar") ? String.Empty : ".tar"));
// Set internal variables
TarArchive oldTarFile = TarArchive.Create();
TarArchive tarFile = TarArchive.Create();
Stream tarstream = new MemoryStream();
TarArchive tarchive = TarArchive.Create();
try
{
@@ -1140,120 +1133,42 @@ namespace SabreTools.Helper.Tools
Directory.CreateDirectory(Path.GetDirectoryName(archiveFileName));
}
// If the archive doesn't exist, create it and put the single file
if (!File.Exists(archiveFileName))
// We can only overwrite at this point, sorry
tarstream = File.Open(archiveFileName, FileMode.Create, FileAccess.Write);
// Map all inputs to index
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
for (int i = 0; i < inputFiles.Count; i++)
{
// Map all inputs to index
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
for (int i = 0; i < inputFiles.Count; i++)
{
inputIndexMap.Add(roms[i].Name.Replace('\\', '/'), i);
}
// Sort the keys in TZIP order
List<string> keys = inputIndexMap.Keys.ToList();
keys.Sort(ZipFile.TorrentZipStringCompare);
// Now add all of the files in order
foreach (string key in keys)
{
// Get the index mapped to the key
int index = inputIndexMap[key];
// Copy the input stream to the output
tarFile.AddEntry(roms[index].Name, inputFiles[index]);
}
inputIndexMap.Add(roms[i].Name.Replace('\\', '/'), i);
}
// Otherwise, sort the input files and write out in the correct order
else
// Sort the keys in TZIP order
List<string> keys = inputIndexMap.Keys.ToList();
keys.Sort(ZipFile.TorrentZipStringCompare);
// Now add each of the files
foreach (string key in keys)
{
// Open the old archive for reading
oldTarFile = TarArchive.Open(archiveFileName);
// Get a list of all current entries
List<string> entries = oldTarFile.Entries.Select(i => i.Key).ToList();
// Map all inputs to index
Dictionary<string, int> inputIndexMap = new Dictionary<string, int>();
for (int i = 0; i < inputFiles.Count; i++)
{
// If the old one contains the new file, then just skip out
if (entries.Contains(roms[i].Name.Replace('\\', '/')))
{
continue;
}
inputIndexMap.Add(roms[i].Name.Replace('\\', '/'), -(i + 1));
}
// Then add all of the old entries to it too
for (int i = 0; i < entries.Count; i++)
{
inputIndexMap.Add(entries[i], i);
}
// If the number of entries is the same as the old archive, skip out
if (inputIndexMap.Keys.Count <= entries.Count)
{
success = true;
return success;
}
// Get the order for the entries with the new file
List<string> keys = inputIndexMap.Keys.ToList();
keys.Sort(ZipFile.TorrentZipStringCompare);
// Copy over all files to the new archive
foreach (string key in keys)
{
// Get the index mapped to the key
int index = inputIndexMap[key];
// If we have the input file, add it now
if (index < 0)
{
// Copy the input file to the output
tarFile.AddEntry(roms[-index - 1].Name, inputFiles[-index - 1]);
}
// Otherwise, copy the file from the old archive
else
{
// Get the stream from the original archive
MemoryStream readStream = new MemoryStream();
oldTarFile.Entries.Where(e => e.Key == key).ToList()[0].WriteTo(readStream);
// Copy the input stream to the output
tarFile.AddEntry(key, readStream);
}
}
int index = inputIndexMap[key];
tarchive.AddEntry(key, inputFiles[index]);
}
// Close the output tar file
tarFile.SaveTo(tempFile, new WriterOptions(CompressionType.None));
tarchive.SaveTo(tarstream, new WriterOptions(CompressionType.None));
success = true;
}
catch (Exception ex)
{
Console.WriteLine(ex);
success = false;
logger.Error(ex.ToString());
}
finally
{
tarFile.Dispose();
oldTarFile.Dispose();
tarstream?.Dispose();
tarchive?.Dispose();
}
// If the old file exists, delete it and replace
if (File.Exists(archiveFileName))
{
File.Delete(archiveFileName);
}
File.Move(tempFile, archiveFileName);
return true;
return success;
}
/// <summary>

View File

@@ -79,7 +79,7 @@ namespace SabreTools.Helper.Tools
}
// Read the input file, if possible
logger.Verbose("Attempting to read file to get format: \"" + filename + "\"");
logger.Verbose("Attempting to read file to get format: "" + filename + """);
// Check if file exists
if (!File.Exists(filename))
@@ -437,7 +437,7 @@ namespace SabreTools.Helper.Tools
/// <returns>The XmlTextReader representing the (possibly converted) file, null otherwise</returns>
public static XmlReader GetXmlTextReader(string filename, Logger logger)
{
logger.Verbose("Attempting to read file: \"" + filename + "\"");
logger.Verbose("Attempting to read file: "" + filename + """);
// Check if file exists
if (!File.Exists(filename))

View File

@@ -7,12 +7,12 @@ using System.Runtime.InteropServices;
// associated with an assembly.
[assembly: AssemblyTitle("SabreTools")]
[assembly: AssemblyDescription("DAT manipulation toolset")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyConfiguration(String.Empty)]
[assembly: AssemblyCompany(String.Empty)]
[assembly: AssemblyProduct("SabreTools")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyTrademark(String.Empty)]
[assembly: AssemblyCulture(String.Empty)]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from