[ALL] Fix String.Empty

This commit is contained in:
Matt Nadareski
2017-01-27 16:40:58 -08:00
parent d1df5c2b60
commit c02a115c98
15 changed files with 379 additions and 294 deletions

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 String.Empty:
case "":
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