[ALL] Update string check; add output path helper

This commit is contained in:
Matt Nadareski
2017-11-08 13:15:44 -08:00
parent bd27b486f8
commit de16014af9
23 changed files with 397 additions and 410 deletions

View File

@@ -377,7 +377,7 @@ namespace RombaSharp
private static void RefreshDatabase() private static void RefreshDatabase()
{ {
// Make sure the db is set // Make sure the db is set
if (String.IsNullOrEmpty(_db)) if (String.IsNullOrWhiteSpace(_db))
{ {
_db = "db.sqlite"; _db = "db.sqlite";
_connectionString = "Data Source=" + _db + ";Version = 3;"; _connectionString = "Data Source=" + _db + ";Version = 3;";
@@ -390,7 +390,7 @@ namespace RombaSharp
} }
// Make sure the dats dir is set // Make sure the dats dir is set
if (String.IsNullOrEmpty(_dats)) if (String.IsNullOrWhiteSpace(_dats))
{ {
_dats = "dats"; _dats = "dats";
} }
@@ -500,23 +500,23 @@ namespace RombaSharp
{ {
Rom rom = (Rom)datItem; Rom rom = (Rom)datItem;
if (!String.IsNullOrEmpty(rom.CRC)) if (!String.IsNullOrWhiteSpace(rom.CRC))
{ {
crcquery += " (\"" + rom.CRC + "\"),"; crcquery += " (\"" + rom.CRC + "\"),";
} }
if (!String.IsNullOrEmpty(rom.MD5)) if (!String.IsNullOrWhiteSpace(rom.MD5))
{ {
md5query += " (\"" + rom.MD5 + "\"),"; md5query += " (\"" + rom.MD5 + "\"),";
} }
if (!String.IsNullOrEmpty(rom.SHA1)) if (!String.IsNullOrWhiteSpace(rom.SHA1))
{ {
sha1query += " (\"" + rom.SHA1 + "\"),"; sha1query += " (\"" + rom.SHA1 + "\"),";
if (!String.IsNullOrEmpty(rom.CRC)) if (!String.IsNullOrWhiteSpace(rom.CRC))
{ {
crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),"; crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),";
} }
if (!String.IsNullOrEmpty(rom.MD5)) if (!String.IsNullOrWhiteSpace(rom.MD5))
{ {
md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),"; md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),";
} }
@@ -526,15 +526,15 @@ namespace RombaSharp
{ {
Disk disk = (Disk)datItem; Disk disk = (Disk)datItem;
if (!String.IsNullOrEmpty(disk.MD5)) if (!String.IsNullOrWhiteSpace(disk.MD5))
{ {
md5query += " (\"" + disk.MD5 + "\"),"; md5query += " (\"" + disk.MD5 + "\"),";
} }
if (!String.IsNullOrEmpty(disk.SHA1)) if (!String.IsNullOrWhiteSpace(disk.SHA1))
{ {
sha1query += " (\"" + disk.SHA1 + "\"),"; sha1query += " (\"" + disk.SHA1 + "\"),";
if (!String.IsNullOrEmpty(disk.MD5)) if (!String.IsNullOrWhiteSpace(disk.MD5))
{ {
md5sha1query += " (\"" + disk.MD5 + "\", \"" + disk.SHA1 + "\"),"; md5sha1query += " (\"" + disk.MD5 + "\", \"" + disk.SHA1 + "\"),";
} }
@@ -642,23 +642,23 @@ namespace RombaSharp
} }
else if (!dupehashes.Contains(rom.SHA1)) else if (!dupehashes.Contains(rom.SHA1))
{ {
if (!String.IsNullOrEmpty(rom.CRC)) if (!String.IsNullOrWhiteSpace(rom.CRC))
{ {
crcquery += " (\"" + rom.CRC + "\"),"; crcquery += " (\"" + rom.CRC + "\"),";
} }
if (!String.IsNullOrEmpty(rom.MD5)) if (!String.IsNullOrWhiteSpace(rom.MD5))
{ {
md5query += " (\"" + rom.MD5 + "\"),"; md5query += " (\"" + rom.MD5 + "\"),";
} }
if (!String.IsNullOrEmpty(rom.SHA1)) if (!String.IsNullOrWhiteSpace(rom.SHA1))
{ {
sha1query += " (\"" + rom.SHA1 + "\", \"" + depotname + "\"),"; sha1query += " (\"" + rom.SHA1 + "\", \"" + depotname + "\"),";
if (!String.IsNullOrEmpty(rom.CRC)) if (!String.IsNullOrWhiteSpace(rom.CRC))
{ {
crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),"; crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),";
} }
if (!String.IsNullOrEmpty(rom.MD5)) if (!String.IsNullOrWhiteSpace(rom.MD5))
{ {
md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),"; md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),";
} }

View File

@@ -84,23 +84,23 @@ namespace RombaSharp
if (sldr.HasRows) if (sldr.HasRows)
{ {
// Add to the queries // Add to the queries
if (!String.IsNullOrEmpty(rom.CRC)) if (!String.IsNullOrWhiteSpace(rom.CRC))
{ {
crcquery += " (\"" + rom.CRC + "\"),"; crcquery += " (\"" + rom.CRC + "\"),";
} }
if (!String.IsNullOrEmpty(rom.MD5)) if (!String.IsNullOrWhiteSpace(rom.MD5))
{ {
md5query += " (\"" + rom.MD5 + "\"),"; md5query += " (\"" + rom.MD5 + "\"),";
} }
if (!String.IsNullOrEmpty(rom.SHA1)) if (!String.IsNullOrWhiteSpace(rom.SHA1))
{ {
sha1query += " (\"" + rom.SHA1 + "\", \"" + _depots.Keys.ToList()[0] + "\"),"; sha1query += " (\"" + rom.SHA1 + "\", \"" + _depots.Keys.ToList()[0] + "\"),";
if (!String.IsNullOrEmpty(rom.CRC)) if (!String.IsNullOrWhiteSpace(rom.CRC))
{ {
crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),"; crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),";
} }
if (!String.IsNullOrEmpty(rom.MD5)) if (!String.IsNullOrWhiteSpace(rom.MD5))
{ {
md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),"; md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),";
} }
@@ -114,23 +114,23 @@ namespace RombaSharp
else else
{ {
// Add to the queries // Add to the queries
if (!String.IsNullOrEmpty(rom.CRC)) if (!String.IsNullOrWhiteSpace(rom.CRC))
{ {
crcquery += " (\"" + rom.CRC + "\"),"; crcquery += " (\"" + rom.CRC + "\"),";
} }
if (!String.IsNullOrEmpty(rom.MD5)) if (!String.IsNullOrWhiteSpace(rom.MD5))
{ {
md5query += " (\"" + rom.MD5 + "\"),"; md5query += " (\"" + rom.MD5 + "\"),";
} }
if (!String.IsNullOrEmpty(rom.SHA1)) if (!String.IsNullOrWhiteSpace(rom.SHA1))
{ {
sha1query += " (\"" + rom.SHA1 + "\", \"" + _depots.Keys.ToList()[0] + "\"),"; sha1query += " (\"" + rom.SHA1 + "\", \"" + _depots.Keys.ToList()[0] + "\"),";
if (!String.IsNullOrEmpty(rom.CRC)) if (!String.IsNullOrWhiteSpace(rom.CRC))
{ {
crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),"; crcsha1query += " (\"" + rom.CRC + "\", \"" + rom.SHA1 + "\"),";
} }
if (!String.IsNullOrEmpty(rom.MD5)) if (!String.IsNullOrWhiteSpace(rom.MD5))
{ {
md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),"; md5sha1query += " (\"" + rom.MD5 + "\", \"" + rom.SHA1 + "\"),";
} }

View File

@@ -495,11 +495,11 @@ namespace SabreTools.Library.DatFiles
if (line.Trim().StartsWith("Name:")) if (line.Trim().StartsWith("Name:"))
{ {
Name = (String.IsNullOrEmpty(Name) ? line.Substring(6) : Name); Name = (String.IsNullOrWhiteSpace(Name) ? line.Substring(6) : Name);
superdat = superdat || itemval.Contains(" - SuperDAT"); superdat = superdat || itemval.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
{ {
Type = (String.IsNullOrEmpty(Type) ? "SuperDAT" : Type); Type = (String.IsNullOrWhiteSpace(Type) ? "SuperDAT" : Type);
} }
continue; continue;
} }
@@ -508,54 +508,54 @@ namespace SabreTools.Library.DatFiles
{ {
case "name": case "name":
case "Name:": case "Name:":
Name = (String.IsNullOrEmpty(Name) ? itemval : Name); Name = (String.IsNullOrWhiteSpace(Name) ? itemval : Name);
superdat = superdat || itemval.Contains(" - SuperDAT"); superdat = superdat || itemval.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
{ {
Type = (String.IsNullOrEmpty(Type) ? "SuperDAT" : Type); Type = (String.IsNullOrWhiteSpace(Type) ? "SuperDAT" : Type);
} }
break; break;
case "description": case "description":
case "Description:": case "Description:":
Description = (String.IsNullOrEmpty(Description) ? itemval : Description); Description = (String.IsNullOrWhiteSpace(Description) ? itemval : Description);
break; break;
case "rootdir": case "rootdir":
RootDir = (String.IsNullOrEmpty(RootDir) ? itemval : RootDir); RootDir = (String.IsNullOrWhiteSpace(RootDir) ? itemval : RootDir);
break; break;
case "category": case "category":
Category = (String.IsNullOrEmpty(Category) ? itemval : Category); Category = (String.IsNullOrWhiteSpace(Category) ? itemval : Category);
break; break;
case "version": case "version":
case "Version:": case "Version:":
Version = (String.IsNullOrEmpty(Version) ? itemval : Version); Version = (String.IsNullOrWhiteSpace(Version) ? itemval : Version);
break; break;
case "date": case "date":
case "Date:": case "Date:":
Date = (String.IsNullOrEmpty(Date) ? itemval : Date); Date = (String.IsNullOrWhiteSpace(Date) ? itemval : Date);
break; break;
case "author": case "author":
case "Author:": case "Author:":
Author = (String.IsNullOrEmpty(Author) ? itemval : Author); Author = (String.IsNullOrWhiteSpace(Author) ? itemval : Author);
break; break;
case "email": case "email":
Email = (String.IsNullOrEmpty(Email) ? itemval : Email); Email = (String.IsNullOrWhiteSpace(Email) ? itemval : Email);
break; break;
case "homepage": case "homepage":
case "Homepage:": case "Homepage:":
Homepage = (String.IsNullOrEmpty(Homepage) ? itemval : Homepage); Homepage = (String.IsNullOrWhiteSpace(Homepage) ? itemval : Homepage);
break; break;
case "url": case "url":
Url = (String.IsNullOrEmpty(Url) ? itemval : Url); Url = (String.IsNullOrWhiteSpace(Url) ? itemval : Url);
break; break;
case "comment": case "comment":
case "Comment:": case "Comment:":
Comment = (String.IsNullOrEmpty(Comment) ? itemval : Comment); Comment = (String.IsNullOrWhiteSpace(Comment) ? itemval : Comment);
break; break;
case "header": case "header":
Header = (String.IsNullOrEmpty(Header) ? itemval : Header); Header = (String.IsNullOrWhiteSpace(Header) ? itemval : Header);
break; break;
case "type": case "type":
Type = (String.IsNullOrEmpty(Type) ? itemval : Type); Type = (String.IsNullOrWhiteSpace(Type) ? itemval : Type);
superdat = superdat || itemval.Contains("SuperDAT"); superdat = superdat || itemval.Contains("SuperDAT");
break; break;
case "forcemerging": case "forcemerging":
@@ -741,14 +741,14 @@ namespace SabreTools.Library.DatFiles
string header = "clrmamepro (\n" + string header = "clrmamepro (\n" +
"\tname \"" + Name + "\"\n" + "\tname \"" + Name + "\"\n" +
"\tdescription \"" + Description + "\"\n" + "\tdescription \"" + Description + "\"\n" +
(!String.IsNullOrEmpty(Category) ? "\tcategory \"" + Category + "\"\n" : "") + (!String.IsNullOrWhiteSpace(Category) ? "\tcategory \"" + Category + "\"\n" : "") +
"\tversion \"" + Version + "\"\n" + "\tversion \"" + Version + "\"\n" +
(!String.IsNullOrEmpty(Date) ? "\tdate \"" + Date + "\"\n" : "") + (!String.IsNullOrWhiteSpace(Date) ? "\tdate \"" + Date + "\"\n" : "") +
"\tauthor \"" + Author + "\"\n" + "\tauthor \"" + Author + "\"\n" +
(!String.IsNullOrEmpty(Email) ? "\temail \"" + Email + "\"\n" : "") + (!String.IsNullOrWhiteSpace(Email) ? "\temail \"" + Email + "\"\n" : "") +
(!String.IsNullOrEmpty(Homepage) ? "\thomepage \"" + Homepage + "\"\n" : "") + (!String.IsNullOrWhiteSpace(Homepage) ? "\thomepage \"" + Homepage + "\"\n" : "") +
(!String.IsNullOrEmpty(Url) ? "\turl \"" + Url + "\"\n" : "") + (!String.IsNullOrWhiteSpace(Url) ? "\turl \"" + Url + "\"\n" : "") +
(!String.IsNullOrEmpty(Comment) ? "\tcomment \"" + Comment + "\"\n" : "") + (!String.IsNullOrWhiteSpace(Comment) ? "\tcomment \"" + Comment + "\"\n" : "") +
(ForcePacking == ForcePacking.Unzip ? "\tforcezipping no\n" : "") + (ForcePacking == ForcePacking.Unzip ? "\tforcezipping no\n" : "") +
(ForcePacking == ForcePacking.Zip ? "\tforcezipping yes\n" : "") + (ForcePacking == ForcePacking.Zip ? "\tforcezipping yes\n" : "") +
(ForceMerging == ForceMerging.Full ? "\tforcemerging full\n" : "") + (ForceMerging == ForceMerging.Full ? "\tforcemerging full\n" : "") +
@@ -788,13 +788,13 @@ namespace SabreTools.Library.DatFiles
string state = "game (\n\tname \"" + rom.MachineName + "\"\n" + string state = "game (\n\tname \"" + rom.MachineName + "\"\n" +
(ExcludeOf ? "" : (ExcludeOf ? "" :
(String.IsNullOrEmpty(rom.RomOf) ? "" : "\tromof \"" + rom.RomOf + "\"\n") + (String.IsNullOrWhiteSpace(rom.RomOf) ? "" : "\tromof \"" + rom.RomOf + "\"\n") +
(String.IsNullOrEmpty(rom.CloneOf) ? "" : "\tcloneof \"" + rom.CloneOf + "\"\n") + (String.IsNullOrWhiteSpace(rom.CloneOf) ? "" : "\tcloneof \"" + rom.CloneOf + "\"\n") +
(String.IsNullOrEmpty(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") (String.IsNullOrWhiteSpace(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n")
) + ) +
"\tdescription \"" + (String.IsNullOrEmpty(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription) + "\"\n" + "\tdescription \"" + (String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription) + "\"\n" +
(String.IsNullOrEmpty(rom.Year) ? "" : "\tyear " + rom.Year + "\n") + (String.IsNullOrWhiteSpace(rom.Year) ? "" : "\tyear " + rom.Year + "\n") +
(String.IsNullOrEmpty(rom.Manufacturer) ? "" : "\tmanufacturer \"" + rom.Manufacturer + "\"\n"); (String.IsNullOrWhiteSpace(rom.Manufacturer) ? "" : "\tmanufacturer \"" + rom.Manufacturer + "\"\n");
sw.Write(state); sw.Write(state);
sw.Flush(); sw.Flush();
@@ -818,7 +818,7 @@ namespace SabreTools.Library.DatFiles
{ {
try try
{ {
string state = (String.IsNullOrEmpty(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") + ")\n"; string state = (String.IsNullOrWhiteSpace(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") + ")\n";
sw.Write(state); sw.Write(state);
sw.Flush(); sw.Flush();
@@ -861,7 +861,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case ItemType.BiosSet: case ItemType.BiosSet:
state += "\tbiosset ( name\"" + rom.Name + "\"" state += "\tbiosset ( name\"" + rom.Name + "\""
+ (!String.IsNullOrEmpty(((BiosSet)rom).Description) ? " description \"" + ((BiosSet)rom).Description + "\"" : "") + (!String.IsNullOrWhiteSpace(((BiosSet)rom).Description) ? " description \"" + ((BiosSet)rom).Description + "\"" : "")
+ (((BiosSet)rom).Default != null + (((BiosSet)rom).Default != null
? "default " + ((BiosSet)rom).Default.ToString().ToLowerInvariant() ? "default " + ((BiosSet)rom).Default.ToString().ToLowerInvariant()
: "") : "")
@@ -869,19 +869,19 @@ namespace SabreTools.Library.DatFiles
break; break;
case ItemType.Disk: case ItemType.Disk:
state += "\tdisk ( name \"" + rom.Name + "\"" state += "\tdisk ( name \"" + rom.Name + "\""
+ (!String.IsNullOrEmpty(((Disk)rom).MD5) ? " md5 " + ((Disk)rom).MD5.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).MD5) ? " md5 " + ((Disk)rom).MD5.ToLowerInvariant() : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA1) ? " sha1 " + ((Disk)rom).SHA1.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA1) ? " sha1 " + ((Disk)rom).SHA1.ToLowerInvariant() : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA256) ? " sha256 " + ((Disk)rom).SHA256.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA256) ? " sha256 " + ((Disk)rom).SHA256.ToLowerInvariant() : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA384) ? " sha384 " + ((Disk)rom).SHA384.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA384) ? " sha384 " + ((Disk)rom).SHA384.ToLowerInvariant() : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA512) ? " sha512 " + ((Disk)rom).SHA512.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA512) ? " sha512 " + ((Disk)rom).SHA512.ToLowerInvariant() : "")
+ (((Disk)rom).ItemStatus != ItemStatus.None ? " flags " + ((Disk)rom).ItemStatus.ToString().ToLowerInvariant() : "") + (((Disk)rom).ItemStatus != ItemStatus.None ? " flags " + ((Disk)rom).ItemStatus.ToString().ToLowerInvariant() : "")
+ " )\n"; + " )\n";
break; break;
case ItemType.Release: case ItemType.Release:
state += "\trelease ( name\"" + rom.Name + "\"" state += "\trelease ( name\"" + rom.Name + "\""
+ (!String.IsNullOrEmpty(((Release)rom).Region) ? " region \"" + ((Release)rom).Region + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Region) ? " region \"" + ((Release)rom).Region + "\"" : "")
+ (!String.IsNullOrEmpty(((Release)rom).Language) ? " language \"" + ((Release)rom).Language + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Language) ? " language \"" + ((Release)rom).Language + "\"" : "")
+ (!String.IsNullOrEmpty(((Release)rom).Date) ? " date \"" + ((Release)rom).Date + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Date) ? " date \"" + ((Release)rom).Date + "\"" : "")
+ (((Release)rom).Default != null + (((Release)rom).Default != null
? "default " + ((Release)rom).Default.ToString().ToLowerInvariant() ? "default " + ((Release)rom).Default.ToString().ToLowerInvariant()
: "") : "")
@@ -890,13 +890,13 @@ namespace SabreTools.Library.DatFiles
case ItemType.Rom: case ItemType.Rom:
state += "\trom ( name \"" + rom.Name + "\"" state += "\trom ( name \"" + rom.Name + "\""
+ (((Rom)rom).Size != -1 ? " size " + ((Rom)rom).Size : "") + (((Rom)rom).Size != -1 ? " size " + ((Rom)rom).Size : "")
+ (!String.IsNullOrEmpty(((Rom)rom).CRC) ? " crc " + ((Rom)rom).CRC.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).CRC) ? " crc " + ((Rom)rom).CRC.ToLowerInvariant() : "")
+ (!String.IsNullOrEmpty(((Rom)rom).MD5) ? " md5 " + ((Rom)rom).MD5.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).MD5) ? " md5 " + ((Rom)rom).MD5.ToLowerInvariant() : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA1) ? " sha1 " + ((Rom)rom).SHA1.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA1) ? " sha1 " + ((Rom)rom).SHA1.ToLowerInvariant() : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA256) ? " sha256 " + ((Rom)rom).SHA256.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA256) ? " sha256 " + ((Rom)rom).SHA256.ToLowerInvariant() : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA384) ? " sha384 " + ((Rom)rom).SHA384.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA384) ? " sha384 " + ((Rom)rom).SHA384.ToLowerInvariant() : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA512) ? " sha512 " + ((Rom)rom).SHA512.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA512) ? " sha512 " + ((Rom)rom).SHA512.ToLowerInvariant() : "")
+ (!String.IsNullOrEmpty(((Rom)rom).Date) ? " date \"" + ((Rom)rom).Date + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).Date) ? " date \"" + ((Rom)rom).Date + "\"" : "")
+ (((Rom)rom).ItemStatus != ItemStatus.None ? " flags " + ((Rom)rom).ItemStatus.ToString().ToLowerInvariant() : "") + (((Rom)rom).ItemStatus != ItemStatus.None ? " flags " + ((Rom)rom).ItemStatus.ToString().ToLowerInvariant() : "")
+ " )\n"; + " )\n";
break; break;

View File

@@ -1518,7 +1518,7 @@ namespace SabreTools.Library.DatFiles
: item.SystemID.ToString().PadLeft(10, '0') : item.SystemID.ToString().PadLeft(10, '0')
+ "-" + "-"
+ item.SourceID.ToString().PadLeft(10, '0') + "-") + item.SourceID.ToString().PadLeft(10, '0') + "-")
+ (String.IsNullOrEmpty(item.MachineName) + (String.IsNullOrWhiteSpace(item.MachineName)
? "Default" ? "Default"
: item.MachineName); : item.MachineName);
if (lower) if (lower)
@@ -1625,6 +1625,9 @@ namespace SabreTools.Library.DatFiles
public void DetermineUpdateType(List<string> inputPaths, List<string> basePaths, string outDir, bool merge, UpdateMode updateMode, bool inplace, bool skip, public void DetermineUpdateType(List<string> inputPaths, List<string> basePaths, string outDir, bool merge, UpdateMode updateMode, bool inplace, bool skip,
bool bare, bool clean, bool remUnicode, bool descAsName, Filter filter, SplitType splitType, bool trim, bool single, string root) bool bare, bool clean, bool remUnicode, bool descAsName, Filter filter, SplitType splitType, bool trim, bool single, string root)
{ {
// First, we want to ensure the output directory
outDir = Utilities.EnsureOutputDirectory(outDir);
// If we're in merging or diffing mode, use the full list of inputs // If we're in merging or diffing mode, use the full list of inputs
if (merge || (updateMode != UpdateMode.None if (merge || (updateMode != UpdateMode.None
&& (updateMode & UpdateMode.DiffAgainst) == 0) && (updateMode & UpdateMode.DiffAgainst) == 0)
@@ -1830,32 +1833,18 @@ namespace SabreTools.Library.DatFiles
}); });
// Determine the output path for the DAT // Determine the output path for the DAT
string interOutDir = outDir; string interOutDir = Utilities.EnsureOutputDirectory(outDir);
if (inplace) if (inplace)
{ {
interOutDir = Path.GetDirectoryName(splitpath[1]); interOutDir = Path.GetDirectoryName(splitpath[1]);
} }
else if (!String.IsNullOrEmpty(interOutDir)) else if (splitpath[0].Length == splitpath[1].Length)
{ {
if (splitpath[0].Length == splitpath[1].Length) interOutDir = Path.GetDirectoryName(Path.Combine(interOutDir, Path.GetFileName(splitpath[0])));
{
interOutDir = Path.GetDirectoryName(Path.Combine(interOutDir, Path.GetFileName(splitpath[0])));
}
else
{
interOutDir = Path.GetDirectoryName(Path.Combine(interOutDir, splitpath[0].Remove(0, splitpath[1].Length + 1)));
}
} }
else else
{ {
if (splitpath[0].Length == splitpath[1].Length) interOutDir = Path.GetDirectoryName(Path.Combine(interOutDir, splitpath[0].Remove(0, splitpath[1].Length + 1)));
{
interOutDir = Path.GetDirectoryName(Path.Combine(Environment.CurrentDirectory, Path.GetFileName(splitpath[0])));
}
else
{
interOutDir = Path.GetDirectoryName(Path.Combine(Environment.CurrentDirectory, splitpath[0].Remove(0, splitpath[1].Length + 1)));
}
} }
// Once we're done, try writing out // Once we're done, try writing out
@@ -1934,32 +1923,18 @@ namespace SabreTools.Library.DatFiles
}); });
// Determine the output path for the DAT // Determine the output path for the DAT
string interOutDir = outDir; string interOutDir = Utilities.EnsureOutputDirectory(outDir);
if (inplace) if (inplace)
{ {
interOutDir = Path.GetDirectoryName(splitpath[1]); interOutDir = Path.GetDirectoryName(splitpath[1]);
} }
else if (!String.IsNullOrEmpty(interOutDir)) else if (splitpath[0].Length == splitpath[1].Length)
{ {
if (splitpath[0].Length == splitpath[1].Length) interOutDir = Path.GetDirectoryName(Path.Combine(interOutDir, Path.GetFileName(splitpath[0])));
{
interOutDir = Path.GetDirectoryName(Path.Combine(interOutDir, Path.GetFileName(splitpath[0])));
}
else
{
interOutDir = Path.GetDirectoryName(Path.Combine(interOutDir, splitpath[0].Remove(0, splitpath[1].Length + 1)));
}
} }
else else
{ {
if (splitpath[0].Length == splitpath[1].Length) interOutDir = Path.GetDirectoryName(Path.Combine(interOutDir, splitpath[0].Remove(0, splitpath[1].Length + 1)));
{
interOutDir = Path.GetDirectoryName(Path.Combine(Environment.CurrentDirectory, Path.GetFileName(splitpath[0])));
}
else
{
interOutDir = Path.GetDirectoryName(Path.Combine(Environment.CurrentDirectory, splitpath[0].Remove(0, splitpath[1].Length + 1)));
}
} }
// Once we're done, try writing out // Once we're done, try writing out
@@ -2086,15 +2061,15 @@ namespace SabreTools.Library.DatFiles
DatFile dupeData = new DatFile(); DatFile dupeData = new DatFile();
// Fill in any information not in the base DAT // Fill in any information not in the base DAT
if (String.IsNullOrEmpty(FileName)) if (String.IsNullOrWhiteSpace(FileName))
{ {
FileName = "All DATs"; FileName = "All DATs";
} }
if (String.IsNullOrEmpty(Name)) if (String.IsNullOrWhiteSpace(Name))
{ {
Name = "All DATs"; Name = "All DATs";
} }
if (String.IsNullOrEmpty(Description)) if (String.IsNullOrWhiteSpace(Description))
{ {
Description = "All DATs"; Description = "All DATs";
} }
@@ -2514,25 +2489,25 @@ namespace SabreTools.Library.DatFiles
foreach (DatItem item in items) foreach (DatItem item in items)
{ {
// Update machine name // Update machine name
if (!String.IsNullOrEmpty(item.MachineName) && mapping.ContainsKey(item.MachineName)) if (!String.IsNullOrWhiteSpace(item.MachineName) && mapping.ContainsKey(item.MachineName))
{ {
item.MachineName = mapping[item.MachineName]; item.MachineName = mapping[item.MachineName];
} }
// Update cloneof // Update cloneof
if (!String.IsNullOrEmpty(item.CloneOf) && mapping.ContainsKey(item.CloneOf)) if (!String.IsNullOrWhiteSpace(item.CloneOf) && mapping.ContainsKey(item.CloneOf))
{ {
item.CloneOf = mapping[item.CloneOf]; item.CloneOf = mapping[item.CloneOf];
} }
// Update romof // Update romof
if (!String.IsNullOrEmpty(item.RomOf) && mapping.ContainsKey(item.RomOf)) if (!String.IsNullOrWhiteSpace(item.RomOf) && mapping.ContainsKey(item.RomOf))
{ {
item.RomOf = mapping[item.RomOf]; item.RomOf = mapping[item.RomOf];
} }
// Update sampleof // Update sampleof
if (!String.IsNullOrEmpty(item.SampleOf) && mapping.ContainsKey(item.SampleOf)) if (!String.IsNullOrWhiteSpace(item.SampleOf) && mapping.ContainsKey(item.SampleOf))
{ {
item.SampleOf = mapping[item.SampleOf]; item.SampleOf = mapping[item.SampleOf];
} }
@@ -2820,13 +2795,13 @@ namespace SabreTools.Library.DatFiles
// Determine if the game has a parent or not // Determine if the game has a parent or not
string parent = null; string parent = null;
if (!String.IsNullOrEmpty(this[game][0].RomOf)) if (!String.IsNullOrWhiteSpace(this[game][0].RomOf))
{ {
parent = this[game][0].RomOf; parent = this[game][0].RomOf;
} }
// If the parent doesnt exist, we want to continue // If the parent doesnt exist, we want to continue
if (String.IsNullOrEmpty(parent)) if (String.IsNullOrWhiteSpace(parent))
{ {
continue; continue;
} }
@@ -2908,13 +2883,13 @@ namespace SabreTools.Library.DatFiles
// Determine if the game has a parent or not // Determine if the game has a parent or not
string parent = null; string parent = null;
if (!String.IsNullOrEmpty(this[game][0].CloneOf)) if (!String.IsNullOrWhiteSpace(this[game][0].CloneOf))
{ {
parent = this[game][0].CloneOf; parent = this[game][0].CloneOf;
} }
// If the parent doesnt exist, we want to continue // If the parent doesnt exist, we want to continue
if (String.IsNullOrEmpty(parent)) if (String.IsNullOrWhiteSpace(parent))
{ {
continue; continue;
} }
@@ -2958,13 +2933,13 @@ namespace SabreTools.Library.DatFiles
{ {
// Determine if the game has a parent or not // Determine if the game has a parent or not
string parent = null; string parent = null;
if (!String.IsNullOrEmpty(this[game][0].CloneOf)) if (!String.IsNullOrWhiteSpace(this[game][0].CloneOf))
{ {
parent = this[game][0].CloneOf; parent = this[game][0].CloneOf;
} }
// If there is no parent, then we continue // If there is no parent, then we continue
if (String.IsNullOrEmpty(parent)) if (String.IsNullOrWhiteSpace(parent))
{ {
continue; continue;
} }
@@ -3034,13 +3009,13 @@ namespace SabreTools.Library.DatFiles
// Determine if the game has a parent or not // Determine if the game has a parent or not
string parent = null; string parent = null;
if (!String.IsNullOrEmpty(this[game][0].RomOf)) if (!String.IsNullOrWhiteSpace(this[game][0].RomOf))
{ {
parent = this[game][0].RomOf; parent = this[game][0].RomOf;
} }
// If the parent doesnt exist, we want to continue // If the parent doesnt exist, we want to continue
if (String.IsNullOrEmpty(parent)) if (String.IsNullOrWhiteSpace(parent))
{ {
continue; continue;
} }
@@ -3077,13 +3052,13 @@ namespace SabreTools.Library.DatFiles
// Determine if the game has a parent or not // Determine if the game has a parent or not
string parent = null; string parent = null;
if (!String.IsNullOrEmpty(this[game][0].CloneOf)) if (!String.IsNullOrWhiteSpace(this[game][0].CloneOf))
{ {
parent = this[game][0].CloneOf; parent = this[game][0].CloneOf;
} }
// If the parent doesnt exist, we want to continue // If the parent doesnt exist, we want to continue
if (String.IsNullOrEmpty(parent)) if (String.IsNullOrWhiteSpace(parent))
{ {
continue; continue;
} }
@@ -3196,7 +3171,7 @@ namespace SabreTools.Library.DatFiles
} }
// If the output filename isn't set already, get the internal filename // If the output filename isn't set already, get the internal filename
FileName = (String.IsNullOrEmpty(FileName) ? (keepext ? Path.GetFileName(filename) : Path.GetFileNameWithoutExtension(filename)) : FileName); FileName = (String.IsNullOrWhiteSpace(FileName) ? (keepext ? Path.GetFileName(filename) : Path.GetFileNameWithoutExtension(filename)) : FileName);
// If the output type isn't set already, get the internal output type // If the output type isn't set already, get the internal output type
DatFormat = (DatFormat == 0 ? Utilities.GetDatFormat(filename) : DatFormat); DatFormat = (DatFormat == 0 ? Utilities.GetDatFormat(filename) : DatFormat);
@@ -3370,7 +3345,7 @@ namespace SabreTools.Library.DatFiles
// 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 ((itemRom.Size == 0 || itemRom.Size == -1) if ((itemRom.Size == 0 || itemRom.Size == -1)
&& ((itemRom.CRC == Constants.CRCZero || String.IsNullOrEmpty(itemRom.CRC)) && ((itemRom.CRC == Constants.CRCZero || String.IsNullOrWhiteSpace(itemRom.CRC))
|| itemRom.MD5 == Constants.MD5Zero || itemRom.MD5 == Constants.MD5Zero
|| itemRom.SHA1 == Constants.SHA1Zero || itemRom.SHA1 == Constants.SHA1Zero
|| itemRom.SHA256 == Constants.SHA256Zero || itemRom.SHA256 == Constants.SHA256Zero
@@ -3398,12 +3373,12 @@ namespace SabreTools.Library.DatFiles
// If the file has a size but aboslutely no hashes, skip and log // If the file has a size but aboslutely no hashes, skip and log
else if (itemRom.ItemStatus != ItemStatus.Nodump else if (itemRom.ItemStatus != ItemStatus.Nodump
&& itemRom.Size > 0 && itemRom.Size > 0
&& String.IsNullOrEmpty(itemRom.CRC) && String.IsNullOrWhiteSpace(itemRom.CRC)
&& String.IsNullOrEmpty(itemRom.MD5) && String.IsNullOrWhiteSpace(itemRom.MD5)
&& String.IsNullOrEmpty(itemRom.SHA1) && String.IsNullOrWhiteSpace(itemRom.SHA1)
&& String.IsNullOrEmpty(itemRom.SHA256) && String.IsNullOrWhiteSpace(itemRom.SHA256)
&& String.IsNullOrEmpty(itemRom.SHA384) && String.IsNullOrWhiteSpace(itemRom.SHA384)
&& String.IsNullOrEmpty(itemRom.SHA512)) && String.IsNullOrWhiteSpace(itemRom.SHA512))
{ {
Globals.Logger.Verbose("{0}: Incomplete entry for '{1}' will be output as nodump", FileName, itemRom.Name); Globals.Logger.Verbose("{0}: Incomplete entry for '{1}' will be output as nodump", FileName, itemRom.Name);
itemRom.ItemStatus = ItemStatus.Nodump; itemRom.ItemStatus = ItemStatus.Nodump;
@@ -3424,11 +3399,11 @@ namespace SabreTools.Library.DatFiles
// If the file has aboslutely no hashes, skip and log // If the file has aboslutely no hashes, skip and log
if (itemDisk.ItemStatus != ItemStatus.Nodump if (itemDisk.ItemStatus != ItemStatus.Nodump
&& String.IsNullOrEmpty(itemDisk.MD5) && String.IsNullOrWhiteSpace(itemDisk.MD5)
&& String.IsNullOrEmpty(itemDisk.SHA1) && String.IsNullOrWhiteSpace(itemDisk.SHA1)
&& String.IsNullOrEmpty(itemDisk.SHA256) && String.IsNullOrWhiteSpace(itemDisk.SHA256)
&& String.IsNullOrEmpty(itemDisk.SHA384) && String.IsNullOrWhiteSpace(itemDisk.SHA384)
&& String.IsNullOrEmpty(itemDisk.SHA512)) && String.IsNullOrWhiteSpace(itemDisk.SHA512))
{ {
Globals.Logger.Verbose("Incomplete entry for '{0}' will be output as nodump", itemDisk.Name); Globals.Logger.Verbose("Incomplete entry for '{0}' will be output as nodump", itemDisk.Name);
itemDisk.ItemStatus = ItemStatus.Nodump; itemDisk.ItemStatus = ItemStatus.Nodump;
@@ -3498,19 +3473,19 @@ namespace SabreTools.Library.DatFiles
bool addBlanks, bool addDate, string tempDir, bool copyFiles, string headerToCheckAgainst, bool chdsAsFiles) bool addBlanks, bool addDate, string tempDir, bool copyFiles, string headerToCheckAgainst, bool chdsAsFiles)
{ {
// If the description is defined but not the name, set the name from the description // If the description is defined but not the name, set the name from the description
if (String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Description)) if (String.IsNullOrWhiteSpace(Name) && !String.IsNullOrWhiteSpace(Description))
{ {
Name = Description; Name = Description;
} }
// If the name is defined but not the description, set the description from the name // If the name is defined but not the description, set the description from the name
else if (!String.IsNullOrEmpty(Name) && String.IsNullOrEmpty(Description)) else if (!String.IsNullOrWhiteSpace(Name) && String.IsNullOrWhiteSpace(Description))
{ {
Description = Name + (bare ? "" : " (" + Date + ")"); Description = Name + (bare ? "" : " (" + Date + ")");
} }
// If neither the name or description are defined, set them from the automatic values // If neither the name or description are defined, set them from the automatic values
else if (String.IsNullOrEmpty(Name) && String.IsNullOrEmpty(Description)) else if (String.IsNullOrWhiteSpace(Name) && String.IsNullOrWhiteSpace(Description))
{ {
Name = basePath.Split(Path.DirectorySeparatorChar).Last(); Name = basePath.Split(Path.DirectorySeparatorChar).Last();
Description = Name + (bare ? "" : " (" + Date + ")"); Description = Name + (bare ? "" : " (" + Date + ")");
@@ -3856,7 +3831,7 @@ namespace SabreTools.Library.DatFiles
{ {
romname = romname.Substring(0, romname.Length - 1); romname = romname.Substring(0, romname.Length - 1);
} }
if (!String.IsNullOrEmpty(gamename) && String.IsNullOrEmpty(romname)) if (!String.IsNullOrWhiteSpace(gamename) && String.IsNullOrWhiteSpace(romname))
{ {
romname = gamename; romname = gamename;
gamename = "Default"; gamename = "Default";
@@ -4518,7 +4493,7 @@ namespace SabreTools.Library.DatFiles
} }
writeStream.Dispose(); writeStream.Dispose();
if (date && !String.IsNullOrEmpty(item.Date)) if (date && !String.IsNullOrWhiteSpace(item.Date))
{ {
File.SetCreationTime(outfile, DateTime.Parse(item.Date)); File.SetCreationTime(outfile, DateTime.Parse(item.Date));
} }
@@ -5107,38 +5082,38 @@ namespace SabreTools.Library.DatFiles
nodump.Add(key, item); nodump.Add(key, item);
} }
// If the file has a SHA-512 // If the file has a SHA-512
else if ((item.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)item).SHA512)) else if ((item.Type == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)item).SHA512))
|| (item.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)item).SHA512))) || (item.Type == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)item).SHA512)))
{ {
sha512.Add(key, item); sha512.Add(key, item);
} }
// If the file has a SHA-384 // If the file has a SHA-384
else if ((item.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)item).SHA384)) else if ((item.Type == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)item).SHA384))
|| (item.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)item).SHA384))) || (item.Type == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)item).SHA384)))
{ {
sha384.Add(key, item); sha384.Add(key, item);
} }
// If the file has a SHA-256 // If the file has a SHA-256
else if ((item.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)item).SHA256)) else if ((item.Type == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)item).SHA256))
|| (item.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)item).SHA256))) || (item.Type == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)item).SHA256)))
{ {
sha256.Add(key, item); sha256.Add(key, item);
} }
// If the file has a SHA-1 // If the file has a SHA-1
else if ((item.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)item).SHA1)) else if ((item.Type == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)item).SHA1))
|| (item.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)item).SHA1))) || (item.Type == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)item).SHA1)))
{ {
sha1.Add(key, item); sha1.Add(key, item);
} }
// If the file has no SHA-1 but has an MD5 // If the file has no SHA-1 but has an MD5
else if ((item.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)item).MD5)) else if ((item.Type == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)item).MD5))
|| (item.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)item).MD5))) || (item.Type == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)item).MD5)))
{ {
md5.Add(key, item); md5.Add(key, item);
} }
// If the file has no MD5 but a CRC // If the file has no MD5 but a CRC
else if ((item.Type == ItemType.Rom && !String.IsNullOrEmpty(((Rom)item).SHA1)) else if ((item.Type == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)item).SHA1))
|| (item.Type == ItemType.Disk && !String.IsNullOrEmpty(((Disk)item).SHA1))) || (item.Type == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)item).SHA1)))
{ {
crc.Add(key, item); crc.Add(key, item);
} }
@@ -5266,12 +5241,12 @@ namespace SabreTools.Library.DatFiles
string expName = name.Replace("/", " - ").Replace("\\", " - "); string expName = name.Replace("/", " - ").Replace("\\", " - ");
// Get the path that the file will be written out to // Get the path that the file will be written out to
string path = HttpUtility.HtmlDecode(String.IsNullOrEmpty(name) string path = HttpUtility.HtmlDecode(String.IsNullOrWhiteSpace(name)
? outDir ? outDir
: Path.Combine(outDir, name)); : Path.Combine(outDir, name));
// Now set the new output values // Now set the new output values
datFile.FileName = HttpUtility.HtmlDecode(String.IsNullOrEmpty(name) datFile.FileName = HttpUtility.HtmlDecode(String.IsNullOrWhiteSpace(name)
? FileName ? FileName
: (shortname : (shortname
? Path.GetFileName(name) ? Path.GetFileName(name)
@@ -5280,7 +5255,7 @@ namespace SabreTools.Library.DatFiles
); );
datFile.FileName = (restore ? FileName + " (" + datFile.FileName + ")" : datFile.FileName); datFile.FileName = (restore ? FileName + " (" + datFile.FileName + ")" : datFile.FileName);
datFile.Name = Name + " (" + expName + ")"; datFile.Name = Name + " (" + expName + ")";
datFile.Description = (String.IsNullOrEmpty(Description) ? datFile.Name : Description + " (" + expName + ")"); datFile.Description = (String.IsNullOrWhiteSpace(Description) ? datFile.Name : Description + " (" + expName + ")");
datFile.Type = null; datFile.Type = null;
// Write out the temporary DAT to the proper directory // Write out the temporary DAT to the proper directory
@@ -5512,18 +5487,8 @@ namespace SabreTools.Library.DatFiles
return false; return false;
} }
// If output directory is empty, use the current folder // Ensure the output directory is set and created
if (outDir == null || outDir.Trim() == "") outDir = Utilities.EnsureOutputDirectory(outDir, create: true);
{
Globals.Logger.Verbose("No output directory defined, defaulting to curent folder");
outDir = Environment.CurrentDirectory;
}
// Create the output directory if it doesn't already exist
if (!Directory.Exists(outDir))
{
Directory.CreateDirectory(outDir);
}
// If the DAT has no output format, default to XML // If the DAT has no output format, default to XML
if (DatFormat == 0) if (DatFormat == 0)
@@ -5533,35 +5498,35 @@ namespace SabreTools.Library.DatFiles
} }
// Make sure that the three essential fields are filled in // Make sure that the three essential fields are filled in
if (String.IsNullOrEmpty(FileName) && String.IsNullOrEmpty(Name) && String.IsNullOrEmpty(Description)) if (String.IsNullOrWhiteSpace(FileName) && String.IsNullOrWhiteSpace(Name) && String.IsNullOrWhiteSpace(Description))
{ {
FileName = Name = Description = "Default"; FileName = Name = Description = "Default";
} }
else if (String.IsNullOrEmpty(FileName) && String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Description)) else if (String.IsNullOrWhiteSpace(FileName) && String.IsNullOrWhiteSpace(Name) && !String.IsNullOrWhiteSpace(Description))
{ {
FileName = Name = Description; FileName = Name = Description;
} }
else if (String.IsNullOrEmpty(FileName) && !String.IsNullOrEmpty(Name) && String.IsNullOrEmpty(Description)) else if (String.IsNullOrWhiteSpace(FileName) && !String.IsNullOrWhiteSpace(Name) && String.IsNullOrWhiteSpace(Description))
{ {
FileName = Description = Name; FileName = Description = Name;
} }
else if (String.IsNullOrEmpty(FileName) && !String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Description)) else if (String.IsNullOrWhiteSpace(FileName) && !String.IsNullOrWhiteSpace(Name) && !String.IsNullOrWhiteSpace(Description))
{ {
FileName = Description; FileName = Description;
} }
else if (!String.IsNullOrEmpty(FileName) && String.IsNullOrEmpty(Name) && String.IsNullOrEmpty(Description)) else if (!String.IsNullOrWhiteSpace(FileName) && String.IsNullOrWhiteSpace(Name) && String.IsNullOrWhiteSpace(Description))
{ {
Name = Description = FileName; Name = Description = FileName;
} }
else if (!String.IsNullOrEmpty(FileName) && String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Description)) else if (!String.IsNullOrWhiteSpace(FileName) && String.IsNullOrWhiteSpace(Name) && !String.IsNullOrWhiteSpace(Description))
{ {
Name = Description; Name = Description;
} }
else if (!String.IsNullOrEmpty(FileName) && !String.IsNullOrEmpty(Name) && String.IsNullOrEmpty(Description)) else if (!String.IsNullOrWhiteSpace(FileName) && !String.IsNullOrWhiteSpace(Name) && String.IsNullOrWhiteSpace(Description))
{ {
Description = Name; Description = Name;
} }
else if (!String.IsNullOrEmpty(FileName) && !String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Description)) else if (!String.IsNullOrWhiteSpace(FileName) && !String.IsNullOrWhiteSpace(Name) && !String.IsNullOrWhiteSpace(Description))
{ {
// Nothing is needed // Nothing is needed
} }
@@ -5863,7 +5828,7 @@ namespace SabreTools.Library.DatFiles
/// <returns>String containing the new filename</returns> /// <returns>String containing the new filename</returns>
private string CreateOutfileNamesHelper(string outDir, string extension, bool overwrite) private string CreateOutfileNamesHelper(string outDir, string extension, bool overwrite)
{ {
string filename = (String.IsNullOrEmpty(FileName) ? Description : FileName); string filename = (String.IsNullOrWhiteSpace(FileName) ? Description : FileName);
string outfile = outDir + filename + extension; string outfile = outDir + filename + extension;
outfile = (outfile.Contains(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString()) ? outfile = (outfile.Contains(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString()) ?
outfile.Replace(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString(), Path.DirectorySeparatorChar.ToString()) : outfile.Replace(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString(), Path.DirectorySeparatorChar.ToString()) :
@@ -5911,17 +5876,13 @@ namespace SabreTools.Library.DatFiles
} }
// Get the proper output file name // Get the proper output file name
if (String.IsNullOrEmpty(reportName)) if (String.IsNullOrWhiteSpace(reportName))
{ {
reportName = "report"; reportName = "report";
} }
// Get the proper output directory name // Get the proper output directory name
if (outDir == null) outDir = Utilities.EnsureOutputDirectory(outDir);
{
outDir = Environment.CurrentDirectory;
}
outDir = Path.GetFullPath(outDir);
// Get the dictionary of desired output report names // Get the dictionary of desired output report names
Dictionary<StatReportFormat, string> outputs = CreateOutStatsNames(outDir, statDatFormat, reportName); Dictionary<StatReportFormat, string> outputs = CreateOutStatsNames(outDir, statDatFormat, reportName);

View File

@@ -196,11 +196,11 @@ namespace SabreTools.Library.DatFiles
_diskCount += 1; _diskCount += 1;
if (((Disk)item).ItemStatus != ItemStatus.Nodump) if (((Disk)item).ItemStatus != ItemStatus.Nodump)
{ {
_md5Count += (String.IsNullOrEmpty(((Disk)item).MD5) ? 0 : 1); _md5Count += (String.IsNullOrWhiteSpace(((Disk)item).MD5) ? 0 : 1);
_sha1Count += (String.IsNullOrEmpty(((Disk)item).SHA1) ? 0 : 1); _sha1Count += (String.IsNullOrWhiteSpace(((Disk)item).SHA1) ? 0 : 1);
_sha256Count += (String.IsNullOrEmpty(((Disk)item).SHA256) ? 0 : 1); _sha256Count += (String.IsNullOrWhiteSpace(((Disk)item).SHA256) ? 0 : 1);
_sha384Count += (String.IsNullOrEmpty(((Disk)item).SHA384) ? 0 : 1); _sha384Count += (String.IsNullOrWhiteSpace(((Disk)item).SHA384) ? 0 : 1);
_sha512Count += (String.IsNullOrEmpty(((Disk)item).SHA512) ? 0 : 1); _sha512Count += (String.IsNullOrWhiteSpace(((Disk)item).SHA512) ? 0 : 1);
} }
_baddumpCount += (((Disk)item).ItemStatus == ItemStatus.BadDump ? 1 : 0); _baddumpCount += (((Disk)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
@@ -216,12 +216,12 @@ namespace SabreTools.Library.DatFiles
if (((Rom)item).ItemStatus != ItemStatus.Nodump) if (((Rom)item).ItemStatus != ItemStatus.Nodump)
{ {
_totalSize += ((Rom)item).Size; _totalSize += ((Rom)item).Size;
_crcCount += (String.IsNullOrEmpty(((Rom)item).CRC) ? 0 : 1); _crcCount += (String.IsNullOrWhiteSpace(((Rom)item).CRC) ? 0 : 1);
_md5Count += (String.IsNullOrEmpty(((Rom)item).MD5) ? 0 : 1); _md5Count += (String.IsNullOrWhiteSpace(((Rom)item).MD5) ? 0 : 1);
_sha1Count += (String.IsNullOrEmpty(((Rom)item).SHA1) ? 0 : 1); _sha1Count += (String.IsNullOrWhiteSpace(((Rom)item).SHA1) ? 0 : 1);
_sha256Count += (String.IsNullOrEmpty(((Rom)item).SHA256) ? 0 : 1); _sha256Count += (String.IsNullOrWhiteSpace(((Rom)item).SHA256) ? 0 : 1);
_sha384Count += (String.IsNullOrEmpty(((Rom)item).SHA384) ? 0 : 1); _sha384Count += (String.IsNullOrWhiteSpace(((Rom)item).SHA384) ? 0 : 1);
_sha512Count += (String.IsNullOrEmpty(((Rom)item).SHA512) ? 0 : 1); _sha512Count += (String.IsNullOrWhiteSpace(((Rom)item).SHA512) ? 0 : 1);
} }
_baddumpCount += (((Rom)item).ItemStatus == ItemStatus.BadDump ? 1 : 0); _baddumpCount += (((Rom)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
@@ -295,11 +295,11 @@ namespace SabreTools.Library.DatFiles
_diskCount -= 1; _diskCount -= 1;
if (((Disk)item).ItemStatus != ItemStatus.Nodump) if (((Disk)item).ItemStatus != ItemStatus.Nodump)
{ {
_md5Count -= (String.IsNullOrEmpty(((Disk)item).MD5) ? 0 : 1); _md5Count -= (String.IsNullOrWhiteSpace(((Disk)item).MD5) ? 0 : 1);
_sha1Count -= (String.IsNullOrEmpty(((Disk)item).SHA1) ? 0 : 1); _sha1Count -= (String.IsNullOrWhiteSpace(((Disk)item).SHA1) ? 0 : 1);
_sha256Count -= (String.IsNullOrEmpty(((Disk)item).SHA256) ? 0 : 1); _sha256Count -= (String.IsNullOrWhiteSpace(((Disk)item).SHA256) ? 0 : 1);
_sha384Count -= (String.IsNullOrEmpty(((Disk)item).SHA384) ? 0 : 1); _sha384Count -= (String.IsNullOrWhiteSpace(((Disk)item).SHA384) ? 0 : 1);
_sha512Count -= (String.IsNullOrEmpty(((Disk)item).SHA512) ? 0 : 1); _sha512Count -= (String.IsNullOrWhiteSpace(((Disk)item).SHA512) ? 0 : 1);
} }
_baddumpCount -= (((Disk)item).ItemStatus == ItemStatus.BadDump ? 1 : 0); _baddumpCount -= (((Disk)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
@@ -315,12 +315,12 @@ namespace SabreTools.Library.DatFiles
if (((Rom)item).ItemStatus != ItemStatus.Nodump) if (((Rom)item).ItemStatus != ItemStatus.Nodump)
{ {
_totalSize -= ((Rom)item).Size; _totalSize -= ((Rom)item).Size;
_crcCount -= (String.IsNullOrEmpty(((Rom)item).CRC) ? 0 : 1); _crcCount -= (String.IsNullOrWhiteSpace(((Rom)item).CRC) ? 0 : 1);
_md5Count -= (String.IsNullOrEmpty(((Rom)item).MD5) ? 0 : 1); _md5Count -= (String.IsNullOrWhiteSpace(((Rom)item).MD5) ? 0 : 1);
_sha1Count -= (String.IsNullOrEmpty(((Rom)item).SHA1) ? 0 : 1); _sha1Count -= (String.IsNullOrWhiteSpace(((Rom)item).SHA1) ? 0 : 1);
_sha256Count -= (String.IsNullOrEmpty(((Rom)item).SHA256) ? 0 : 1); _sha256Count -= (String.IsNullOrWhiteSpace(((Rom)item).SHA256) ? 0 : 1);
_sha384Count -= (String.IsNullOrEmpty(((Rom)item).SHA384) ? 0 : 1); _sha384Count -= (String.IsNullOrWhiteSpace(((Rom)item).SHA384) ? 0 : 1);
_sha512Count -= (String.IsNullOrEmpty(((Rom)item).SHA512) ? 0 : 1); _sha512Count -= (String.IsNullOrWhiteSpace(((Rom)item).SHA512) ? 0 : 1);
} }
_baddumpCount -= (((Rom)item).ItemStatus == ItemStatus.BadDump ? 1 : 0); _baddumpCount -= (((Rom)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);

View File

@@ -238,7 +238,7 @@ namespace SabreTools.Library.DatFiles
{ {
try try
{ {
string state = (String.IsNullOrEmpty(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") + ")\n"; string state = (String.IsNullOrWhiteSpace(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") + ")\n";
sw.Write(state); sw.Write(state);
sw.Flush(); sw.Flush();
@@ -284,8 +284,8 @@ namespace SabreTools.Library.DatFiles
case ItemType.Rom: case ItemType.Rom:
state += "\tfile ( name " + ((Rom)rom).Name state += "\tfile ( name " + ((Rom)rom).Name
+ (((Rom)rom).Size != -1 ? " size " + ((Rom)rom).Size : "") + (((Rom)rom).Size != -1 ? " size " + ((Rom)rom).Size : "")
+ (!String.IsNullOrEmpty(((Rom)rom).Date) ? " date " + ((Rom)rom).Date : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).Date) ? " date " + ((Rom)rom).Date : "")
+ (!String.IsNullOrEmpty(((Rom)rom).CRC) ? " crc " + ((Rom)rom).CRC.ToLowerInvariant() : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).CRC) ? " crc " + ((Rom)rom).CRC.ToLowerInvariant() : "")
+ " )\n"; + " )\n";
break; break;
} }

View File

@@ -621,7 +621,7 @@ namespace SabreTools.Library.DatFiles
bool found = false; bool found = false;
foreach (string straw in haystack) foreach (string straw in haystack)
{ {
if (!String.IsNullOrEmpty(straw)) if (!String.IsNullOrWhiteSpace(straw))
{ {
string regexStraw = straw; string regexStraw = straw;

View File

@@ -77,7 +77,7 @@ namespace SabreTools.Library.DatFiles
string line = sr.ReadLine().Trim(); string line = sr.ReadLine().Trim();
// If we have a blank line, we just skip it // If we have a blank line, we just skip it
if (String.IsNullOrEmpty(line)) if (String.IsNullOrWhiteSpace(line))
{ {
continue; continue;
} }

View File

@@ -111,7 +111,7 @@ namespace SabreTools.Library.DatFiles
parent.RemoveAt(parent.Count - 1); parent.RemoveAt(parent.Count - 1);
if (keep && parentcount > 1) if (keep && parentcount > 1)
{ {
Type = (String.IsNullOrEmpty(Type) ? "SuperDAT" : Type); Type = (String.IsNullOrWhiteSpace(Type) ? "SuperDAT" : Type);
superdat = true; superdat = true;
} }
} }
@@ -130,8 +130,8 @@ namespace SabreTools.Library.DatFiles
case "mame": case "mame":
if (xtr.GetAttribute("build") != null) if (xtr.GetAttribute("build") != null)
{ {
Name = (String.IsNullOrEmpty(Name) ? xtr.GetAttribute("build") : Name); Name = (String.IsNullOrWhiteSpace(Name) ? xtr.GetAttribute("build") : Name);
Description = (String.IsNullOrEmpty(Description) ? Name : Name); Description = (String.IsNullOrWhiteSpace(Description) ? Name : Name);
} }
xtr.Read(); xtr.Read();
break; break;
@@ -139,11 +139,11 @@ namespace SabreTools.Library.DatFiles
case "softwarelist": case "softwarelist":
if (xtr.GetAttribute("name") != null) if (xtr.GetAttribute("name") != null)
{ {
Name = (String.IsNullOrEmpty(Name) ? xtr.GetAttribute("name") : Name); Name = (String.IsNullOrWhiteSpace(Name) ? xtr.GetAttribute("name") : Name);
} }
if (xtr.GetAttribute("description") != null) if (xtr.GetAttribute("description") != null)
{ {
Description = (String.IsNullOrEmpty(Description) ? xtr.GetAttribute("description") : Description); Description = (String.IsNullOrWhiteSpace(Description) ? xtr.GetAttribute("description") : Description);
} }
if (xtr.GetAttribute("forcemerging") != null && ForceMerging == ForceMerging.None) if (xtr.GetAttribute("forcemerging") != null && ForceMerging == ForceMerging.None)
{ {
@@ -197,11 +197,11 @@ namespace SabreTools.Library.DatFiles
break; break;
// Handle M1 DATs since they're 99% the same as a SL DAT // Handle M1 DATs since they're 99% the same as a SL DAT
case "m1": case "m1":
Name = (String.IsNullOrEmpty(Name) ? "M1" : Name); Name = (String.IsNullOrWhiteSpace(Name) ? "M1" : Name);
Description = (String.IsNullOrEmpty(Description) ? "M1" : Description); Description = (String.IsNullOrWhiteSpace(Description) ? "M1" : Description);
if (xtr.GetAttribute("version") != null) if (xtr.GetAttribute("version") != null)
{ {
Version = (String.IsNullOrEmpty(Version) ? xtr.GetAttribute("version") : Version); Version = (String.IsNullOrWhiteSpace(Version) ? xtr.GetAttribute("version") : Version);
} }
xtr.Read(); xtr.Read();
break; break;
@@ -232,16 +232,16 @@ namespace SabreTools.Library.DatFiles
{ {
case "datname": case "datname":
content = headreader.ReadElementContentAsString(); ; content = headreader.ReadElementContentAsString(); ;
Name = (String.IsNullOrEmpty(Name) ? content : Name); Name = (String.IsNullOrWhiteSpace(Name) ? content : Name);
superdat = superdat || content.Contains(" - SuperDAT"); superdat = superdat || content.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
{ {
Type = (String.IsNullOrEmpty(Type) ? "SuperDAT" : Type); Type = (String.IsNullOrWhiteSpace(Type) ? "SuperDAT" : Type);
} }
break; break;
case "datversionurl": case "datversionurl":
content = headreader.ReadElementContentAsString(); ; content = headreader.ReadElementContentAsString(); ;
Url = (String.IsNullOrEmpty(Name) ? content : Url); Url = (String.IsNullOrWhiteSpace(Name) ? content : Url);
break; break;
default: default:
headreader.Read(); headreader.Read();
@@ -277,75 +277,75 @@ namespace SabreTools.Library.DatFiles
{ {
case "name": case "name":
content = headreader.ReadElementContentAsString(); ; content = headreader.ReadElementContentAsString(); ;
Name = (String.IsNullOrEmpty(Name) ? content : Name); Name = (String.IsNullOrWhiteSpace(Name) ? content : Name);
superdat = superdat || content.Contains(" - SuperDAT"); superdat = superdat || content.Contains(" - SuperDAT");
if (keep && superdat) if (keep && superdat)
{ {
Type = (String.IsNullOrEmpty(Type) ? "SuperDAT" : Type); Type = (String.IsNullOrWhiteSpace(Type) ? "SuperDAT" : Type);
} }
break; break;
case "description": case "description":
content = headreader.ReadElementContentAsString(); content = headreader.ReadElementContentAsString();
Description = (String.IsNullOrEmpty(Description) ? content : Description); Description = (String.IsNullOrWhiteSpace(Description) ? content : Description);
break; break;
case "rootdir": case "rootdir":
content = headreader.ReadElementContentAsString(); content = headreader.ReadElementContentAsString();
RootDir = (String.IsNullOrEmpty(RootDir) ? content : RootDir); RootDir = (String.IsNullOrWhiteSpace(RootDir) ? content : RootDir);
break; break;
case "category": case "category":
content = headreader.ReadElementContentAsString(); content = headreader.ReadElementContentAsString();
Category = (String.IsNullOrEmpty(Category) ? content : Category); Category = (String.IsNullOrWhiteSpace(Category) ? content : Category);
break; break;
case "version": case "version":
content = headreader.ReadElementContentAsString(); content = headreader.ReadElementContentAsString();
Version = (String.IsNullOrEmpty(Version) ? content : Version); Version = (String.IsNullOrWhiteSpace(Version) ? content : Version);
break; break;
case "date": case "date":
content = headreader.ReadElementContentAsString(); content = headreader.ReadElementContentAsString();
Date = (String.IsNullOrEmpty(Date) ? content.Replace(".", "/") : Date); Date = (String.IsNullOrWhiteSpace(Date) ? content.Replace(".", "/") : Date);
break; break;
case "author": case "author":
content = headreader.ReadElementContentAsString(); content = headreader.ReadElementContentAsString();
Author = (String.IsNullOrEmpty(Author) ? content : Author); Author = (String.IsNullOrWhiteSpace(Author) ? content : Author);
// Special cases for SabreDAT // Special cases for SabreDAT
Email = (String.IsNullOrEmpty(Email) && !String.IsNullOrEmpty(headreader.GetAttribute("email")) ? Email = (String.IsNullOrWhiteSpace(Email) && !String.IsNullOrWhiteSpace(headreader.GetAttribute("email")) ?
headreader.GetAttribute("email") : Email); headreader.GetAttribute("email") : Email);
Homepage = (String.IsNullOrEmpty(Homepage) && !String.IsNullOrEmpty(headreader.GetAttribute("homepage")) ? Homepage = (String.IsNullOrWhiteSpace(Homepage) && !String.IsNullOrWhiteSpace(headreader.GetAttribute("homepage")) ?
headreader.GetAttribute("homepage") : Homepage); headreader.GetAttribute("homepage") : Homepage);
Url = (String.IsNullOrEmpty(Url) && !String.IsNullOrEmpty(headreader.GetAttribute("url")) ? Url = (String.IsNullOrWhiteSpace(Url) && !String.IsNullOrWhiteSpace(headreader.GetAttribute("url")) ?
headreader.GetAttribute("url") : Url); headreader.GetAttribute("url") : Url);
break; break;
case "email": case "email":
content = headreader.ReadElementContentAsString(); content = headreader.ReadElementContentAsString();
Email = (String.IsNullOrEmpty(Email) ? content : Email); Email = (String.IsNullOrWhiteSpace(Email) ? content : Email);
break; break;
case "homepage": case "homepage":
content = headreader.ReadElementContentAsString(); content = headreader.ReadElementContentAsString();
Homepage = (String.IsNullOrEmpty(Homepage) ? content : Homepage); Homepage = (String.IsNullOrWhiteSpace(Homepage) ? content : Homepage);
break; break;
case "url": case "url":
content = headreader.ReadElementContentAsString(); content = headreader.ReadElementContentAsString();
Url = (String.IsNullOrEmpty(Url) ? content : Url); Url = (String.IsNullOrWhiteSpace(Url) ? content : Url);
break; break;
case "comment": case "comment":
content = headreader.ReadElementContentAsString(); content = headreader.ReadElementContentAsString();
Comment = (String.IsNullOrEmpty(Comment) ? content : Comment); Comment = (String.IsNullOrWhiteSpace(Comment) ? content : Comment);
break; break;
case "type": case "type":
content = headreader.ReadElementContentAsString(); content = headreader.ReadElementContentAsString();
Type = (String.IsNullOrEmpty(Type) ? content : Type); Type = (String.IsNullOrWhiteSpace(Type) ? content : Type);
superdat = superdat || content.Contains("SuperDAT"); superdat = superdat || content.Contains("SuperDAT");
break; break;
case "clrmamepro": case "clrmamepro":
case "romcenter": case "romcenter":
if (headreader.GetAttribute("header") != null) if (headreader.GetAttribute("header") != null)
{ {
Header = (String.IsNullOrEmpty(Header) ? headreader.GetAttribute("header") : Header); Header = (String.IsNullOrWhiteSpace(Header) ? headreader.GetAttribute("header") : Header);
} }
if (headreader.GetAttribute("plugin") != null) if (headreader.GetAttribute("plugin") != null)
{ {
Header = (String.IsNullOrEmpty(Header) ? headreader.GetAttribute("plugin") : Header); Header = (String.IsNullOrWhiteSpace(Header) ? headreader.GetAttribute("plugin") : Header);
} }
if (headreader.GetAttribute("forcemerging") != null && ForceMerging == ForceMerging.None) if (headreader.GetAttribute("forcemerging") != null && ForceMerging == ForceMerging.None)
{ {
@@ -425,7 +425,7 @@ namespace SabreTools.Library.DatFiles
switch (flagreader.GetAttribute("name")) switch (flagreader.GetAttribute("name"))
{ {
case "type": case "type":
Type = (String.IsNullOrEmpty(Type) ? content : Type); Type = (String.IsNullOrWhiteSpace(Type) ? content : Type);
superdat = superdat || content.Contains("SuperDAT"); superdat = superdat || content.Contains("SuperDAT");
break; break;
case "forcemerging": case "forcemerging":
@@ -1288,16 +1288,16 @@ namespace SabreTools.Library.DatFiles
"\t<header>\n" + "\t<header>\n" +
"\t\t<name>" + HttpUtility.HtmlEncode(Name) + "</name>\n" + "\t\t<name>" + HttpUtility.HtmlEncode(Name) + "</name>\n" +
"\t\t<description>" + HttpUtility.HtmlEncode(Description) + "</description>\n" + "\t\t<description>" + HttpUtility.HtmlEncode(Description) + "</description>\n" +
(!String.IsNullOrEmpty(RootDir) ? "\t\t<rootdir>" + HttpUtility.HtmlEncode(RootDir) + "</rootdir>\n" : "") + (!String.IsNullOrWhiteSpace(RootDir) ? "\t\t<rootdir>" + HttpUtility.HtmlEncode(RootDir) + "</rootdir>\n" : "") +
(!String.IsNullOrEmpty(Category) ? "\t\t<category>" + HttpUtility.HtmlEncode(Category) + "</category>\n" : "") + (!String.IsNullOrWhiteSpace(Category) ? "\t\t<category>" + HttpUtility.HtmlEncode(Category) + "</category>\n" : "") +
"\t\t<version>" + HttpUtility.HtmlEncode(Version) + "</version>\n" + "\t\t<version>" + HttpUtility.HtmlEncode(Version) + "</version>\n" +
(!String.IsNullOrEmpty(Date) ? "\t\t<date>" + HttpUtility.HtmlEncode(Date) + "</date>\n" : "") + (!String.IsNullOrWhiteSpace(Date) ? "\t\t<date>" + HttpUtility.HtmlEncode(Date) + "</date>\n" : "") +
"\t\t<author>" + HttpUtility.HtmlEncode(Author) + "</author>\n" + "\t\t<author>" + HttpUtility.HtmlEncode(Author) + "</author>\n" +
(!String.IsNullOrEmpty(Email) ? "\t\t<email>" + HttpUtility.HtmlEncode(Email) + "</email>\n" : "") + (!String.IsNullOrWhiteSpace(Email) ? "\t\t<email>" + HttpUtility.HtmlEncode(Email) + "</email>\n" : "") +
(!String.IsNullOrEmpty(Homepage) ? "\t\t<homepage>" + HttpUtility.HtmlEncode(Homepage) + "</homepage>\n" : "") + (!String.IsNullOrWhiteSpace(Homepage) ? "\t\t<homepage>" + HttpUtility.HtmlEncode(Homepage) + "</homepage>\n" : "") +
(!String.IsNullOrEmpty(Url) ? "\t\t<url>" + HttpUtility.HtmlEncode(Url) + "</url>\n" : "") + (!String.IsNullOrWhiteSpace(Url) ? "\t\t<url>" + HttpUtility.HtmlEncode(Url) + "</url>\n" : "") +
(!String.IsNullOrEmpty(Comment) ? "\t\t<comment>" + HttpUtility.HtmlEncode(Comment) + "</comment>\n" : "") + (!String.IsNullOrWhiteSpace(Comment) ? "\t\t<comment>" + HttpUtility.HtmlEncode(Comment) + "</comment>\n" : "") +
(!String.IsNullOrEmpty(Type) ? "\t\t<type>" + HttpUtility.HtmlEncode(Type) + "</type>\n" : "") + (!String.IsNullOrWhiteSpace(Type) ? "\t\t<type>" + HttpUtility.HtmlEncode(Type) + "</type>\n" : "") +
(ForcePacking != ForcePacking.None || ForceMerging != ForceMerging.None || ForceNodump != ForceNodump.None ? (ForcePacking != ForcePacking.None || ForceMerging != ForceMerging.None || ForceNodump != ForceNodump.None ?
"\t\t<clrmamepro" + "\t\t<clrmamepro" +
(ForcePacking == ForcePacking.Unzip ? " forcepacking=\"unzip\"" : "") + (ForcePacking == ForcePacking.Unzip ? " forcepacking=\"unzip\"" : "") +
@@ -1348,21 +1348,21 @@ namespace SabreTools.Library.DatFiles
(rom.MachineType == MachineType.Device ? " isdevice=\"yes\"" : "") + (rom.MachineType == MachineType.Device ? " isdevice=\"yes\"" : "") +
(rom.MachineType == MachineType.Mechanical ? " ismechanical=\"yes\"" : "") + (rom.MachineType == MachineType.Mechanical ? " ismechanical=\"yes\"" : "") +
(rom.Runnable == true ? " runnable=\"yes\"" : "") + (rom.Runnable == true ? " runnable=\"yes\"" : "") +
(String.IsNullOrEmpty(rom.CloneOf) || (rom.MachineName.ToLowerInvariant() == rom.CloneOf.ToLowerInvariant()) (String.IsNullOrWhiteSpace(rom.CloneOf) || (rom.MachineName.ToLowerInvariant() == rom.CloneOf.ToLowerInvariant())
? "" ? ""
: " cloneof=\"" + HttpUtility.HtmlEncode(rom.CloneOf) + "\"") + : " cloneof=\"" + HttpUtility.HtmlEncode(rom.CloneOf) + "\"") +
(String.IsNullOrEmpty(rom.RomOf) || (rom.MachineName.ToLowerInvariant() == rom.RomOf.ToLowerInvariant()) (String.IsNullOrWhiteSpace(rom.RomOf) || (rom.MachineName.ToLowerInvariant() == rom.RomOf.ToLowerInvariant())
? "" ? ""
: " romof=\"" + HttpUtility.HtmlEncode(rom.RomOf) + "\"") + : " romof=\"" + HttpUtility.HtmlEncode(rom.RomOf) + "\"") +
(String.IsNullOrEmpty(rom.SampleOf) || (rom.MachineName.ToLowerInvariant() == rom.SampleOf.ToLowerInvariant()) (String.IsNullOrWhiteSpace(rom.SampleOf) || (rom.MachineName.ToLowerInvariant() == rom.SampleOf.ToLowerInvariant())
? "" ? ""
: " sampleof=\"" + HttpUtility.HtmlEncode(rom.SampleOf) + "\"") : " sampleof=\"" + HttpUtility.HtmlEncode(rom.SampleOf) + "\"")
) + ) +
">\n" + ">\n" +
(String.IsNullOrEmpty(rom.Comment) ? "" : "\t\t<comment>" + HttpUtility.HtmlEncode(rom.Comment) + "</comment>\n") + (String.IsNullOrWhiteSpace(rom.Comment) ? "" : "\t\t<comment>" + HttpUtility.HtmlEncode(rom.Comment) + "</comment>\n") +
"\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) + "</description>\n" + "\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) + "</description>\n" +
(String.IsNullOrEmpty(rom.Year) ? "" : "\t\t<year>" + HttpUtility.HtmlEncode(rom.Year) + "</year>\n") + (String.IsNullOrWhiteSpace(rom.Year) ? "" : "\t\t<year>" + HttpUtility.HtmlEncode(rom.Year) + "</year>\n") +
(String.IsNullOrEmpty(rom.Manufacturer) ? "" : "\t\t<manufacturer>" + HttpUtility.HtmlEncode(rom.Manufacturer) + "</manufacturer>\n"); (String.IsNullOrWhiteSpace(rom.Manufacturer) ? "" : "\t\t<manufacturer>" + HttpUtility.HtmlEncode(rom.Manufacturer) + "</manufacturer>\n");
sw.Write(state); sw.Write(state);
sw.Flush(); sw.Flush();
@@ -1427,7 +1427,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case ItemType.BiosSet: case ItemType.BiosSet:
state += "\t\t<biosset name\"" + HttpUtility.HtmlEncode(rom.Name) + "\"" state += "\t\t<biosset name\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
+ (!String.IsNullOrEmpty(((BiosSet)rom).Description) ? " description=\"" + HttpUtility.HtmlEncode(((BiosSet)rom).Description) + "\"" : "") + (!String.IsNullOrWhiteSpace(((BiosSet)rom).Description) ? " description=\"" + HttpUtility.HtmlEncode(((BiosSet)rom).Description) + "\"" : "")
+ (((BiosSet)rom).Default != null + (((BiosSet)rom).Default != null
? ((BiosSet)rom).Default.ToString().ToLowerInvariant() ? ((BiosSet)rom).Default.ToString().ToLowerInvariant()
: "") : "")
@@ -1435,19 +1435,19 @@ namespace SabreTools.Library.DatFiles
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).MD5) ? " md5=\"" + ((Disk)rom).MD5.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).MD5) ? " md5=\"" + ((Disk)rom).MD5.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA1) ? " sha1=\"" + ((Disk)rom).SHA1.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA1) ? " sha1=\"" + ((Disk)rom).SHA1.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA256) ? " sha256=\"" + ((Disk)rom).SHA256.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA256) ? " sha256=\"" + ((Disk)rom).SHA256.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA384) ? " sha384=\"" + ((Disk)rom).SHA384.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA384) ? " sha384=\"" + ((Disk)rom).SHA384.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA512) ? " sha512=\"" + ((Disk)rom).SHA512.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA512) ? " sha512=\"" + ((Disk)rom).SHA512.ToLowerInvariant() + "\"" : "")
+ (((Disk)rom).ItemStatus != ItemStatus.None ? " status=\"" + ((Disk)rom).ItemStatus.ToString().ToLowerInvariant() + "\"" : "") + (((Disk)rom).ItemStatus != ItemStatus.None ? " status=\"" + ((Disk)rom).ItemStatus.ToString().ToLowerInvariant() + "\"" : "")
+ "/>\n"; + "/>\n";
break; break;
case ItemType.Release: case ItemType.Release:
state += "\t\t<release name\"" + HttpUtility.HtmlEncode(rom.Name) + "\"" state += "\t\t<release name\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
+ (!String.IsNullOrEmpty(((Release)rom).Region) ? " region=\"" + HttpUtility.HtmlEncode(((Release)rom).Region) + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Region) ? " region=\"" + HttpUtility.HtmlEncode(((Release)rom).Region) + "\"" : "")
+ (!String.IsNullOrEmpty(((Release)rom).Language) ? " language=\"" + HttpUtility.HtmlEncode(((Release)rom).Language) + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Language) ? " language=\"" + HttpUtility.HtmlEncode(((Release)rom).Language) + "\"" : "")
+ (!String.IsNullOrEmpty(((Release)rom).Date) ? " date=\"" + HttpUtility.HtmlEncode(((Release)rom).Date) + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Date) ? " date=\"" + HttpUtility.HtmlEncode(((Release)rom).Date) + "\"" : "")
+ (((Release)rom).Default != null + (((Release)rom).Default != null
? ((Release)rom).Default.ToString().ToLowerInvariant() ? ((Release)rom).Default.ToString().ToLowerInvariant()
: "") : "")
@@ -1456,13 +1456,13 @@ namespace SabreTools.Library.DatFiles
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).Size != -1 ? " size=\"" + ((Rom)rom).Size + "\"" : "") + (((Rom)rom).Size != -1 ? " size=\"" + ((Rom)rom).Size + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).CRC) ? " crc=\"" + ((Rom)rom).CRC.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).CRC) ? " crc=\"" + ((Rom)rom).CRC.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).MD5) ? " md5=\"" + ((Rom)rom).MD5.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).MD5) ? " md5=\"" + ((Rom)rom).MD5.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA1) ? " sha1=\"" + ((Rom)rom).SHA1.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA1) ? " sha1=\"" + ((Rom)rom).SHA1.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA256) ? " sha256=\"" + ((Rom)rom).SHA256.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA256) ? " sha256=\"" + ((Rom)rom).SHA256.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA384) ? " sha384=\"" + ((Rom)rom).SHA384.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA384) ? " sha384=\"" + ((Rom)rom).SHA384.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA512) ? " sha512=\"" + ((Rom)rom).SHA512.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA512) ? " sha512=\"" + ((Rom)rom).SHA512.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).Date) ? " date=\"" + ((Rom)rom).Date + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).Date) ? " date=\"" + ((Rom)rom).Date + "\"" : "")
+ (((Rom)rom).ItemStatus != ItemStatus.None ? " status=\"" + ((Rom)rom).ItemStatus.ToString().ToLowerInvariant() + "\"" : "") + (((Rom)rom).ItemStatus != ItemStatus.None ? " status=\"" + ((Rom)rom).ItemStatus.ToString().ToLowerInvariant() + "\"" : "")
+ "/>\n"; + "/>\n";
break; break;

View File

@@ -91,7 +91,7 @@ namespace SabreTools.Library.DatFiles
// If we have an author // If we have an author
if (line.ToLowerInvariant().StartsWith("author=")) if (line.ToLowerInvariant().StartsWith("author="))
{ {
Author = (String.IsNullOrEmpty(Author) ? line.Split('=')[1] : Author); Author = (String.IsNullOrWhiteSpace(Author) ? line.Split('=')[1] : Author);
} }
// If we have one of the three version tags // If we have one of the three version tags
else if (line.ToLowerInvariant().StartsWith("version=")) else if (line.ToLowerInvariant().StartsWith("version="))
@@ -99,22 +99,22 @@ namespace SabreTools.Library.DatFiles
switch (blocktype) switch (blocktype)
{ {
case "credits": case "credits":
Version = (String.IsNullOrEmpty(Version) ? line.Split('=')[1] : Version); Version = (String.IsNullOrWhiteSpace(Version) ? line.Split('=')[1] : Version);
break; break;
case "emulator": case "emulator":
Description = (String.IsNullOrEmpty(Description) ? line.Split('=')[1] : Description); Description = (String.IsNullOrWhiteSpace(Description) ? line.Split('=')[1] : Description);
break; break;
} }
} }
// If we have a URL // If we have a URL
else if (line.ToLowerInvariant().StartsWith("url=")) else if (line.ToLowerInvariant().StartsWith("url="))
{ {
Url = (String.IsNullOrEmpty(Url) ? line.Split('=')[1] : Url); Url = (String.IsNullOrWhiteSpace(Url) ? line.Split('=')[1] : Url);
} }
// If we have a comment // If we have a comment
else if (line.ToLowerInvariant().StartsWith("comment=")) else if (line.ToLowerInvariant().StartsWith("comment="))
{ {
Comment = (String.IsNullOrEmpty(Comment) ? line.Split('=')[1] : Comment); Comment = (String.IsNullOrWhiteSpace(Comment) ? line.Split('=')[1] : Comment);
} }
// If we have the split flag // If we have the split flag
else if (line.ToLowerInvariant().StartsWith("split=")) else if (line.ToLowerInvariant().StartsWith("split="))
@@ -141,7 +141,7 @@ namespace SabreTools.Library.DatFiles
// If we have the refname tag // If we have the refname tag
else if (line.ToLowerInvariant().StartsWith("refname=")) else if (line.ToLowerInvariant().StartsWith("refname="))
{ {
Name = (String.IsNullOrEmpty(Name) ? line.Split('=')[1] : Name); Name = (String.IsNullOrWhiteSpace(Name) ? line.Split('=')[1] : Name);
} }
// If we have a rom // If we have a rom
else if (line.StartsWith("¬")) else if (line.StartsWith("¬"))
@@ -343,20 +343,20 @@ namespace SabreTools.Library.DatFiles
string state = ""; string state = "";
if (rom.Type == ItemType.Rom) if (rom.Type == ItemType.Rom)
{ {
state += "¬" + (String.IsNullOrEmpty(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) + state += "¬" + (String.IsNullOrWhiteSpace(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) +
"¬" + (String.IsNullOrEmpty(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) + "¬" + (String.IsNullOrWhiteSpace(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) +
"¬" + HttpUtility.HtmlEncode(rom.MachineName) + "¬" + HttpUtility.HtmlEncode(rom.MachineName) +
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) + "¬" + HttpUtility.HtmlEncode((String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) +
"¬" + HttpUtility.HtmlEncode(rom.Name) + "¬" + HttpUtility.HtmlEncode(rom.Name) +
"¬" + ((Rom)rom).CRC.ToLowerInvariant() + "¬" + ((Rom)rom).CRC.ToLowerInvariant() +
"¬" + (((Rom)rom).Size != -1 ? ((Rom)rom).Size.ToString() : "") + "¬¬¬\n"; "¬" + (((Rom)rom).Size != -1 ? ((Rom)rom).Size.ToString() : "") + "¬¬¬\n";
} }
else if (rom.Type == ItemType.Disk) else if (rom.Type == ItemType.Disk)
{ {
state += "¬" + (String.IsNullOrEmpty(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) + state += "¬" + (String.IsNullOrWhiteSpace(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) +
"¬" + (String.IsNullOrEmpty(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) + "¬" + (String.IsNullOrWhiteSpace(rom.CloneOf) ? "" : HttpUtility.HtmlEncode(rom.CloneOf)) +
"¬" + HttpUtility.HtmlEncode(rom.MachineName) + "¬" + HttpUtility.HtmlEncode(rom.MachineName) +
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) + "¬" + HttpUtility.HtmlEncode((String.IsNullOrWhiteSpace(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) +
"¬" + HttpUtility.HtmlEncode(rom.Name) + "¬" + HttpUtility.HtmlEncode(rom.Name) +
"¬¬¬¬¬\n"; "¬¬¬¬¬\n";
} }

View File

@@ -181,15 +181,15 @@ namespace SabreTools.Library.DatFiles
"\t<header>\n" + "\t<header>\n" +
"\t\t<name>" + HttpUtility.HtmlEncode(Name) + "</name>\n" + "\t\t<name>" + HttpUtility.HtmlEncode(Name) + "</name>\n" +
"\t\t<description>" + HttpUtility.HtmlEncode(Description) + "</description>\n" + "\t\t<description>" + HttpUtility.HtmlEncode(Description) + "</description>\n" +
(!String.IsNullOrEmpty(RootDir) ? "\t\t<rootdir>" + HttpUtility.HtmlEncode(RootDir) + "</rootdir>\n" : "") + (!String.IsNullOrWhiteSpace(RootDir) ? "\t\t<rootdir>" + HttpUtility.HtmlEncode(RootDir) + "</rootdir>\n" : "") +
(!String.IsNullOrEmpty(Category) ? "\t\t<category>" + HttpUtility.HtmlEncode(Category) + "</category>\n" : "") + (!String.IsNullOrWhiteSpace(Category) ? "\t\t<category>" + HttpUtility.HtmlEncode(Category) + "</category>\n" : "") +
"\t\t<version>" + HttpUtility.HtmlEncode(Version) + "</version>\n" + "\t\t<version>" + HttpUtility.HtmlEncode(Version) + "</version>\n" +
(!String.IsNullOrEmpty(Date) ? "\t\t<date>" + HttpUtility.HtmlEncode(Date) + "</date>\n" : "") + (!String.IsNullOrWhiteSpace(Date) ? "\t\t<date>" + HttpUtility.HtmlEncode(Date) + "</date>\n" : "") +
"\t\t<author>" + HttpUtility.HtmlEncode(Author) + "</author>\n" + "\t\t<author>" + HttpUtility.HtmlEncode(Author) + "</author>\n" +
(!String.IsNullOrEmpty(Comment) ? "\t\t<comment>" + HttpUtility.HtmlEncode(Comment) + "</comment>\n" : "") + (!String.IsNullOrWhiteSpace(Comment) ? "\t\t<comment>" + HttpUtility.HtmlEncode(Comment) + "</comment>\n" : "") +
(!String.IsNullOrEmpty(Type) || ForcePacking != ForcePacking.None || ForceMerging != ForceMerging.None || ForceNodump != ForceNodump.None ? (!String.IsNullOrWhiteSpace(Type) || ForcePacking != ForcePacking.None || ForceMerging != ForceMerging.None || ForceNodump != ForceNodump.None ?
"\t\t<flags>\n" + "\t\t<flags>\n" +
(!String.IsNullOrEmpty(Type) ? "\t\t\t<flag name=\"type\" value=\"" + HttpUtility.HtmlEncode(Type) + "\"/>\n" : "") + (!String.IsNullOrWhiteSpace(Type) ? "\t\t\t<flag name=\"type\" value=\"" + HttpUtility.HtmlEncode(Type) + "\"/>\n" : "") +
(ForcePacking == ForcePacking.Unzip ? "\t\t\t<flag name=\"forcepacking\" value=\"unzip\"/>\n" : "") + (ForcePacking == ForcePacking.Unzip ? "\t\t\t<flag name=\"forcepacking\" value=\"unzip\"/>\n" : "") +
(ForcePacking == ForcePacking.Zip ? "\t\t\t<flag name=\"forcepacking\" value=\"zip\"/>\n" : "") + (ForcePacking == ForcePacking.Zip ? "\t\t\t<flag name=\"forcepacking\" value=\"zip\"/>\n" : "") +
(ForceMerging == ForceMerging.Full ? "\t\t\t<flag name=\"forcemerging\" value=\"full\"/>\n" : "") + (ForceMerging == ForceMerging.Full ? "\t\t\t<flag name=\"forcemerging\" value=\"full\"/>\n" : "") +
@@ -353,7 +353,7 @@ namespace SabreTools.Library.DatFiles
break; break;
case ItemType.BiosSet: case ItemType.BiosSet:
state += "<file type=\"biosset\" name\"" + HttpUtility.HtmlEncode(rom.Name) + "\"" state += "<file type=\"biosset\" name\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
+ (!String.IsNullOrEmpty(((BiosSet)rom).Description) ? " description=\"" + HttpUtility.HtmlEncode(((BiosSet)rom).Description) + "\"" : "") + (!String.IsNullOrWhiteSpace(((BiosSet)rom).Description) ? " description=\"" + HttpUtility.HtmlEncode(((BiosSet)rom).Description) + "\"" : "")
+ (((BiosSet)rom).Default != null + (((BiosSet)rom).Default != null
? ((BiosSet)rom).Default.ToString().ToLowerInvariant() ? ((BiosSet)rom).Default.ToString().ToLowerInvariant()
: "") : "")
@@ -361,11 +361,11 @@ namespace SabreTools.Library.DatFiles
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).MD5) ? " md5=\"" + ((Disk)rom).MD5.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).MD5) ? " md5=\"" + ((Disk)rom).MD5.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA1) ? " sha1=\"" + ((Disk)rom).SHA1.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA1) ? " sha1=\"" + ((Disk)rom).SHA1.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA256) ? " sha256=\"" + ((Disk)rom).SHA256.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA256) ? " sha256=\"" + ((Disk)rom).SHA256.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA384) ? " sha384=\"" + ((Disk)rom).SHA384.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA384) ? " sha384=\"" + ((Disk)rom).SHA384.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA512) ? " sha512=\"" + ((Disk)rom).SHA512.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA512) ? " sha512=\"" + ((Disk)rom).SHA512.ToLowerInvariant() + "\"" : "")
+ (((Disk)rom).ItemStatus != ItemStatus.None ? prefix + "/>\n" + prefix + "\t<flags>\n" + + (((Disk)rom).ItemStatus != ItemStatus.None ? prefix + "/>\n" + prefix + "\t<flags>\n" +
prefix + "\t\t<flag name=\"status\" value=\"" + ((Disk)rom).ItemStatus.ToString().ToLowerInvariant() + "\"/>\n" + prefix + "\t\t<flag name=\"status\" value=\"" + ((Disk)rom).ItemStatus.ToString().ToLowerInvariant() + "\"/>\n" +
prefix + "\t</flags>\n" + prefix + "\t</flags>\n" +
@@ -373,9 +373,9 @@ namespace SabreTools.Library.DatFiles
break; break;
case ItemType.Release: case ItemType.Release:
state += "<file type=\"release\" name\"" + HttpUtility.HtmlEncode(rom.Name) + "\"" state += "<file type=\"release\" name\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
+ (!String.IsNullOrEmpty(((Release)rom).Region) ? " region=\"" + HttpUtility.HtmlEncode(((Release)rom).Region) + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Region) ? " region=\"" + HttpUtility.HtmlEncode(((Release)rom).Region) + "\"" : "")
+ (!String.IsNullOrEmpty(((Release)rom).Language) ? " language=\"" + HttpUtility.HtmlEncode(((Release)rom).Language) + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Language) ? " language=\"" + HttpUtility.HtmlEncode(((Release)rom).Language) + "\"" : "")
+ (!String.IsNullOrEmpty(((Release)rom).Date) ? " date=\"" + HttpUtility.HtmlEncode(((Release)rom).Date) + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Date) ? " date=\"" + HttpUtility.HtmlEncode(((Release)rom).Date) + "\"" : "")
+ (((Release)rom).Default != null + (((Release)rom).Default != null
? ((Release)rom).Default.ToString().ToLowerInvariant() ? ((Release)rom).Default.ToString().ToLowerInvariant()
: "") : "")
@@ -384,13 +384,13 @@ namespace SabreTools.Library.DatFiles
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).Size != -1 ? " size=\"" + ((Rom)rom).Size + "\"" : "") + (((Rom)rom).Size != -1 ? " size=\"" + ((Rom)rom).Size + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).CRC) ? " crc=\"" + ((Rom)rom).CRC.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).CRC) ? " crc=\"" + ((Rom)rom).CRC.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).MD5) ? " md5=\"" + ((Rom)rom).MD5.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).MD5) ? " md5=\"" + ((Rom)rom).MD5.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA1) ? " sha1=\"" + ((Rom)rom).SHA1.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA1) ? " sha1=\"" + ((Rom)rom).SHA1.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA256) ? " sha256=\"" + ((Rom)rom).SHA256.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA256) ? " sha256=\"" + ((Rom)rom).SHA256.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA384) ? " sha384=\"" + ((Rom)rom).SHA384.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA384) ? " sha384=\"" + ((Rom)rom).SHA384.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA512) ? " sha512=\"" + ((Rom)rom).SHA512.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA512) ? " sha512=\"" + ((Rom)rom).SHA512.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).Date) ? " date=\"" + ((Rom)rom).Date + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).Date) ? " date=\"" + ((Rom)rom).Date + "\"" : "")
+ (((Rom)rom).ItemStatus != ItemStatus.None ? prefix + "/>\n" + prefix + "\t<flags>\n" + + (((Rom)rom).ItemStatus != ItemStatus.None ? prefix + "/>\n" + prefix + "\t<flags>\n" +
prefix + "\t\t<flag name=\"status\" value=\"" + ((Rom)rom).ItemStatus.ToString().ToLowerInvariant() + "\"/>\n" + prefix + "\t\t<flag name=\"status\" value=\"" + ((Rom)rom).ItemStatus.ToString().ToLowerInvariant() + "\"/>\n" +
prefix + "\t</flags>\n" + prefix + "\t</flags>\n" +

View File

@@ -186,13 +186,13 @@ namespace SabreTools.Library.DatFiles
switch (columns[i]) switch (columns[i])
{ {
case "DatFile.FileName": case "DatFile.FileName":
FileName = (String.IsNullOrEmpty(FileName) ? value : FileName); FileName = (String.IsNullOrWhiteSpace(FileName) ? value : FileName);
break; break;
case "DatFile.Name": case "DatFile.Name":
Name = (String.IsNullOrEmpty(Name) ? value : Name); Name = (String.IsNullOrWhiteSpace(Name) ? value : Name);
break; break;
case "DatFile.Description": case "DatFile.Description":
Description = (String.IsNullOrEmpty(Description) ? value : Description); Description = (String.IsNullOrWhiteSpace(Description) ? value : Description);
break; break;
case "Machine.Name": case "Machine.Name":
machineName = value; machineName = value;

View File

@@ -218,13 +218,13 @@ namespace SabreTools.Library.DatFiles
string state = "\t<software name=\"" + HttpUtility.HtmlEncode(rom.MachineName) + "\"" string state = "\t<software name=\"" + HttpUtility.HtmlEncode(rom.MachineName) + "\""
+ (rom.Supported != null ? " supported=\"" + (rom.Supported == true ? "yes" : "no") + "\"" : "") + + (rom.Supported != null ? " supported=\"" + (rom.Supported == true ? "yes" : "no") + "\"" : "") +
(ExcludeOf ? "" : (ExcludeOf ? "" :
(String.IsNullOrEmpty(rom.CloneOf) || (rom.MachineName.ToLowerInvariant() == rom.CloneOf.ToLowerInvariant()) (String.IsNullOrWhiteSpace(rom.CloneOf) || (rom.MachineName.ToLowerInvariant() == rom.CloneOf.ToLowerInvariant())
? "" ? ""
: " cloneof=\"" + HttpUtility.HtmlEncode(rom.CloneOf) + "\"") + : " cloneof=\"" + HttpUtility.HtmlEncode(rom.CloneOf) + "\"") +
(String.IsNullOrEmpty(rom.RomOf) || (rom.MachineName.ToLowerInvariant() == rom.RomOf.ToLowerInvariant()) (String.IsNullOrWhiteSpace(rom.RomOf) || (rom.MachineName.ToLowerInvariant() == rom.RomOf.ToLowerInvariant())
? "" ? ""
: " romof=\"" + HttpUtility.HtmlEncode(rom.RomOf) + "\"") + : " romof=\"" + HttpUtility.HtmlEncode(rom.RomOf) + "\"") +
(String.IsNullOrEmpty(rom.SampleOf) || (rom.MachineName.ToLowerInvariant() == rom.SampleOf.ToLowerInvariant()) (String.IsNullOrWhiteSpace(rom.SampleOf) || (rom.MachineName.ToLowerInvariant() == rom.SampleOf.ToLowerInvariant())
? "" ? ""
: " sampleof=\"" + HttpUtility.HtmlEncode(rom.SampleOf) + "\"") : " sampleof=\"" + HttpUtility.HtmlEncode(rom.SampleOf) + "\"")
) + ">\n" ) + ">\n"
@@ -302,17 +302,17 @@ namespace SabreTools.Library.DatFiles
switch (rom.Type) switch (rom.Type)
{ {
case ItemType.Archive: case ItemType.Archive:
state += "\t\t\t<dataarea name=\"" + (String.IsNullOrEmpty(rom.AreaName) ? "archive" : rom.AreaName) + "\"" state += "\t\t\t<dataarea name=\"" + (String.IsNullOrWhiteSpace(rom.AreaName) ? "archive" : rom.AreaName) + "\""
+ (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n" + (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n"
+ "\t\t\t\t<archive name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\"" + "\t\t\t\t<archive name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
+ "/>\n" + "/>\n"
+ "\t\t\t</dataarea>\n"; + "\t\t\t</dataarea>\n";
break; break;
case ItemType.BiosSet: case ItemType.BiosSet:
state += "\t\t\t<dataarea name=\"" + (String.IsNullOrEmpty(rom.AreaName) ? "biosset" : rom.AreaName) + "\"" state += "\t\t\t<dataarea name=\"" + (String.IsNullOrWhiteSpace(rom.AreaName) ? "biosset" : rom.AreaName) + "\""
+ (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n" + (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n"
+ "\t\t\t\t<biosset name\"" + HttpUtility.HtmlEncode(rom.Name) + "\"" + "\t\t\t\t<biosset name\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
+ (!String.IsNullOrEmpty(((BiosSet)rom).Description) ? " description=\"" + HttpUtility.HtmlEncode(((BiosSet)rom).Description) + "\"" : "") + (!String.IsNullOrWhiteSpace(((BiosSet)rom).Description) ? " description=\"" + HttpUtility.HtmlEncode(((BiosSet)rom).Description) + "\"" : "")
+ (((BiosSet)rom).Default != null + (((BiosSet)rom).Default != null
? ((BiosSet)rom).Default.ToString().ToLowerInvariant() ? ((BiosSet)rom).Default.ToString().ToLowerInvariant()
: "") : "")
@@ -320,25 +320,25 @@ namespace SabreTools.Library.DatFiles
+ "\t\t\t</dataarea>\n"; + "\t\t\t</dataarea>\n";
break; break;
case ItemType.Disk: case ItemType.Disk:
state += "\t\t\t<diskarea name=\"" + (String.IsNullOrEmpty(rom.AreaName) ? "cdrom" : rom.AreaName) + "\"" state += "\t\t\t<diskarea name=\"" + (String.IsNullOrWhiteSpace(rom.AreaName) ? "cdrom" : rom.AreaName) + "\""
+ (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n" + (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n"
+ "\t\t\t\t<disk name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\"" + "\t\t\t\t<disk name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
+ (!String.IsNullOrEmpty(((Disk)rom).MD5) ? " md5=\"" + ((Disk)rom).MD5.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).MD5) ? " md5=\"" + ((Disk)rom).MD5.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA1) ? " sha1=\"" + ((Disk)rom).SHA1.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA1) ? " sha1=\"" + ((Disk)rom).SHA1.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA256) ? " sha256=\"" + ((Disk)rom).SHA256.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA256) ? " sha256=\"" + ((Disk)rom).SHA256.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA384) ? " sha384=\"" + ((Disk)rom).SHA384.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA384) ? " sha384=\"" + ((Disk)rom).SHA384.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Disk)rom).SHA512) ? " sha512=\"" + ((Disk)rom).SHA512.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Disk)rom).SHA512) ? " sha512=\"" + ((Disk)rom).SHA512.ToLowerInvariant() + "\"" : "")
+ (((Disk)rom).ItemStatus != ItemStatus.None ? " status=\"" + ((Disk)rom).ItemStatus.ToString().ToLowerInvariant() + "\"" : "") + (((Disk)rom).ItemStatus != ItemStatus.None ? " status=\"" + ((Disk)rom).ItemStatus.ToString().ToLowerInvariant() + "\"" : "")
+ "/>\n" + "/>\n"
+ "\t\t\t</diskarea>\n"; + "\t\t\t</diskarea>\n";
break; break;
case ItemType.Release: case ItemType.Release:
state += "\t\t\t<dataarea name=\"" + (String.IsNullOrEmpty(rom.AreaName) ? "release" : rom.AreaName) + "\"" state += "\t\t\t<dataarea name=\"" + (String.IsNullOrWhiteSpace(rom.AreaName) ? "release" : rom.AreaName) + "\""
+ (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n" + (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n"
+ "\t\t\t\t<release name\"" + HttpUtility.HtmlEncode(rom.Name) + "\"" + "\t\t\t\t<release name\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
+ (!String.IsNullOrEmpty(((Release)rom).Region) ? " region=\"" + HttpUtility.HtmlEncode(((Release)rom).Region) + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Region) ? " region=\"" + HttpUtility.HtmlEncode(((Release)rom).Region) + "\"" : "")
+ (!String.IsNullOrEmpty(((Release)rom).Language) ? " language=\"" + HttpUtility.HtmlEncode(((Release)rom).Language) + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Language) ? " language=\"" + HttpUtility.HtmlEncode(((Release)rom).Language) + "\"" : "")
+ (!String.IsNullOrEmpty(((Release)rom).Date) ? " date=\"" + HttpUtility.HtmlEncode(((Release)rom).Date) + "\"" : "") + (!String.IsNullOrWhiteSpace(((Release)rom).Date) ? " date=\"" + HttpUtility.HtmlEncode(((Release)rom).Date) + "\"" : "")
+ (((Release)rom).Default != null + (((Release)rom).Default != null
? ((Release)rom).Default.ToString().ToLowerInvariant() ? ((Release)rom).Default.ToString().ToLowerInvariant()
: "") : "")
@@ -346,23 +346,23 @@ namespace SabreTools.Library.DatFiles
+ "\t\t\t</dataarea>\n"; + "\t\t\t</dataarea>\n";
break; break;
case ItemType.Rom: case ItemType.Rom:
state += "\t\t\t<dataarea name=\"" + (String.IsNullOrEmpty(rom.AreaName) ? "rom" : rom.AreaName) + "\"" state += "\t\t\t<dataarea name=\"" + (String.IsNullOrWhiteSpace(rom.AreaName) ? "rom" : rom.AreaName) + "\""
+ (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n" + (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n"
+ "\t\t\t\t<rom name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\"" + "\t\t\t\t<rom name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
+ (((Rom)rom).Size != -1 ? " size=\"" + ((Rom)rom).Size + "\"" : "") + (((Rom)rom).Size != -1 ? " size=\"" + ((Rom)rom).Size + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).CRC) ? " crc=\"" + ((Rom)rom).CRC.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).CRC) ? " crc=\"" + ((Rom)rom).CRC.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).MD5) ? " md5=\"" + ((Rom)rom).MD5.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).MD5) ? " md5=\"" + ((Rom)rom).MD5.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA1) ? " sha1=\"" + ((Rom)rom).SHA1.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA1) ? " sha1=\"" + ((Rom)rom).SHA1.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA256) ? " sha256=\"" + ((Rom)rom).SHA256.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA256) ? " sha256=\"" + ((Rom)rom).SHA256.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA384) ? " sha384=\"" + ((Rom)rom).SHA384.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA384) ? " sha384=\"" + ((Rom)rom).SHA384.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).SHA512) ? " sha512=\"" + ((Rom)rom).SHA512.ToLowerInvariant() + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).SHA512) ? " sha512=\"" + ((Rom)rom).SHA512.ToLowerInvariant() + "\"" : "")
+ (!String.IsNullOrEmpty(((Rom)rom).Date) ? " date=\"" + ((Rom)rom).Date + "\"" : "") + (!String.IsNullOrWhiteSpace(((Rom)rom).Date) ? " date=\"" + ((Rom)rom).Date + "\"" : "")
+ (((Rom)rom).ItemStatus != ItemStatus.None ? " status=\"" + ((Rom)rom).ItemStatus.ToString().ToLowerInvariant() + "\"" : "") + (((Rom)rom).ItemStatus != ItemStatus.None ? " status=\"" + ((Rom)rom).ItemStatus.ToString().ToLowerInvariant() + "\"" : "")
+ "/>\n" + "/>\n"
+ "\t\t\t</dataarea>\n"; + "\t\t\t</dataarea>\n";
break; break;
case ItemType.Sample: case ItemType.Sample:
state += "\t\t\t<dataarea name=\"" + (String.IsNullOrEmpty(rom.AreaName) ? "sample" : rom.AreaName) + "\"" state += "\t\t\t<dataarea name=\"" + (String.IsNullOrWhiteSpace(rom.AreaName) ? "sample" : rom.AreaName) + "\""
+ (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n" + (rom.AreaSize != null ? " size=\"" + rom.AreaSize + "\"" : "") + ">\n"
+ "\t\t\t\t<sample type=\"sample\" name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\"" + "\t\t\t\t<sample type=\"sample\" name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\""
+ "/>\n" + "/>\n"

View File

@@ -654,24 +654,24 @@ namespace SabreTools.Library.DatItems
{ {
// If all items are supposed to have a SHA-512, we sort by that // If all items are supposed to have a SHA-512, we sort by that
if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA512Count if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA512Count
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).SHA512)) && ((_itemType == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)this).SHA512))
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).SHA512)))) || (_itemType == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)this).SHA512))))
{ {
datdata.BucketBy(SortedBy.SHA512, DedupeType.None); datdata.BucketBy(SortedBy.SHA512, DedupeType.None);
} }
// If all items are supposed to have a SHA-384, we sort by that // If all items are supposed to have a SHA-384, we sort by that
else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA384Count else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA384Count
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).SHA384)) && ((_itemType == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)this).SHA384))
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).SHA384)))) || (_itemType == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)this).SHA384))))
{ {
datdata.BucketBy(SortedBy.SHA384, DedupeType.None); datdata.BucketBy(SortedBy.SHA384, DedupeType.None);
} }
// If all items are supposed to have a SHA-256, we sort by that // If all items are supposed to have a SHA-256, we sort by that
else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA256Count else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA256Count
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).SHA256)) && ((_itemType == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)this).SHA256))
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).SHA256)))) || (_itemType == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)this).SHA256))))
{ {
if (_itemType == ItemType.Rom) if (_itemType == ItemType.Rom)
{ {
@@ -687,8 +687,8 @@ namespace SabreTools.Library.DatItems
// If all items are supposed to have a SHA-1, we sort by that // If all items are supposed to have a SHA-1, we sort by that
else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA1Count else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA1Count
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).SHA1)) && ((_itemType == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)this).SHA1))
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).SHA1)))) || (_itemType == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)this).SHA1))))
{ {
if (_itemType == ItemType.Rom) if (_itemType == ItemType.Rom)
{ {
@@ -704,8 +704,8 @@ namespace SabreTools.Library.DatItems
// If all items are supposed to have an MD5, we sort by that // If all items are supposed to have an MD5, we sort by that
else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.MD5Count else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.MD5Count
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).MD5)) && ((_itemType == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)this).MD5))
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).MD5)))) || (_itemType == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)this).MD5))))
{ {
if (_itemType == ItemType.Rom) if (_itemType == ItemType.Rom)
{ {
@@ -887,22 +887,22 @@ namespace SabreTools.Library.DatItems
if (file.Type == ItemType.Rom) if (file.Type == ItemType.Rom)
{ {
((Rom)saveditem).Size = ((Rom)saveditem).Size; ((Rom)saveditem).Size = ((Rom)saveditem).Size;
((Rom)saveditem).CRC = (String.IsNullOrEmpty(((Rom)saveditem).CRC) && !String.IsNullOrEmpty(((Rom)file).CRC) ((Rom)saveditem).CRC = (String.IsNullOrWhiteSpace(((Rom)saveditem).CRC) && !String.IsNullOrWhiteSpace(((Rom)file).CRC)
? ((Rom)file).CRC ? ((Rom)file).CRC
: ((Rom)saveditem).CRC); : ((Rom)saveditem).CRC);
((Rom)saveditem).MD5 = (String.IsNullOrEmpty(((Rom)saveditem).MD5) && !String.IsNullOrEmpty(((Rom)file).MD5) ((Rom)saveditem).MD5 = (String.IsNullOrWhiteSpace(((Rom)saveditem).MD5) && !String.IsNullOrWhiteSpace(((Rom)file).MD5)
? ((Rom)file).MD5 ? ((Rom)file).MD5
: ((Rom)saveditem).MD5); : ((Rom)saveditem).MD5);
((Rom)saveditem).SHA1 = (String.IsNullOrEmpty(((Rom)saveditem).SHA1) && !String.IsNullOrEmpty(((Rom)file).SHA1) ((Rom)saveditem).SHA1 = (String.IsNullOrWhiteSpace(((Rom)saveditem).SHA1) && !String.IsNullOrWhiteSpace(((Rom)file).SHA1)
? ((Rom)file).SHA1 ? ((Rom)file).SHA1
: ((Rom)saveditem).SHA1); : ((Rom)saveditem).SHA1);
} }
else else
{ {
((Disk)saveditem).MD5 = (String.IsNullOrEmpty(((Disk)saveditem).MD5) && !String.IsNullOrEmpty(((Disk)file).MD5) ((Disk)saveditem).MD5 = (String.IsNullOrWhiteSpace(((Disk)saveditem).MD5) && !String.IsNullOrWhiteSpace(((Disk)file).MD5)
? ((Disk)file).MD5 ? ((Disk)file).MD5
: ((Disk)saveditem).MD5); : ((Disk)saveditem).MD5);
((Disk)saveditem).SHA1 = (String.IsNullOrEmpty(((Disk)saveditem).SHA1) && !String.IsNullOrEmpty(((Disk)file).SHA1) ((Disk)saveditem).SHA1 = (String.IsNullOrWhiteSpace(((Disk)saveditem).SHA1) && !String.IsNullOrWhiteSpace(((Disk)file).SHA1)
? ((Disk)file).SHA1 ? ((Disk)file).SHA1
: ((Disk)saveditem).SHA1); : ((Disk)saveditem).SHA1);
} }
@@ -997,9 +997,9 @@ namespace SabreTools.Library.DatItems
if (datItem.Type == ItemType.Disk) if (datItem.Type == ItemType.Disk)
{ {
Disk disk = (Disk)datItem; Disk disk = (Disk)datItem;
disk.Name += "_" + (!String.IsNullOrEmpty(disk.MD5) disk.Name += "_" + (!String.IsNullOrWhiteSpace(disk.MD5)
? disk.MD5 ? disk.MD5
: !String.IsNullOrEmpty(disk.SHA1) : !String.IsNullOrWhiteSpace(disk.SHA1)
? disk.SHA1 ? disk.SHA1
: "1"); : "1");
datItem = disk; datItem = disk;
@@ -1008,11 +1008,11 @@ namespace SabreTools.Library.DatItems
else if (datItem.Type == ItemType.Rom) else if (datItem.Type == ItemType.Rom)
{ {
Rom rom = (Rom)datItem; Rom rom = (Rom)datItem;
rom.Name += "_" + (!String.IsNullOrEmpty(rom.CRC) rom.Name += "_" + (!String.IsNullOrWhiteSpace(rom.CRC)
? rom.CRC ? rom.CRC
: !String.IsNullOrEmpty(rom.MD5) : !String.IsNullOrWhiteSpace(rom.MD5)
? rom.MD5 ? rom.MD5
: !String.IsNullOrEmpty(rom.SHA1) : !String.IsNullOrWhiteSpace(rom.SHA1)
? rom.SHA1 ? rom.SHA1
: "1"); : "1");
datItem = rom; datItem = rom;

View File

@@ -27,27 +27,27 @@ namespace SabreTools.Library.DatItems
// Disk information // Disk information
public string MD5 public string MD5
{ {
get { return _md5.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_md5); } get { return _md5.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_md5); }
set { _md5 = Utilities.StringToByteArray(value); } set { _md5 = Utilities.StringToByteArray(value); }
} }
public string SHA1 public string SHA1
{ {
get { return _sha1.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha1); } get { return _sha1.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha1); }
set { _sha1 = Utilities.StringToByteArray(value); } set { _sha1 = Utilities.StringToByteArray(value); }
} }
public string SHA256 public string SHA256
{ {
get { return _sha256.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha256); } get { return _sha256.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha256); }
set { _sha256 = Utilities.StringToByteArray(value); } set { _sha256 = Utilities.StringToByteArray(value); }
} }
public string SHA384 public string SHA384
{ {
get { return _sha384.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha384); } get { return _sha384.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha384); }
set { _sha384 = Utilities.StringToByteArray(value); } set { _sha384 = Utilities.StringToByteArray(value); }
} }
public string SHA512 public string SHA512
{ {
get { return _sha512.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha512); } get { return _sha512.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha512); }
set { _sha512 = Utilities.StringToByteArray(value); } set { _sha512 = Utilities.StringToByteArray(value); }
} }
public ItemStatus ItemStatus public ItemStatus ItemStatus
@@ -145,19 +145,19 @@ namespace SabreTools.Library.DatItems
} }
// If we can determine that the disks have no non-empty hashes in common, we return false // If we can determine that the disks have no non-empty hashes in common, we return false
if ((this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty()) if ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
&& (this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty()) && (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
&& (this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty()) && (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
&& (this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty()) && (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace())
&& (this._sha512.IsNullOrEmpty() || newOther._sha512.IsNullOrEmpty())) && (this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()))
{ {
dupefound = false; dupefound = false;
} }
else if (((this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._md5, newOther._md5)) else if (((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
&& ((this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1)) && ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
&& ((this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256)) && ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
&& ((this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384)) && ((this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
&& ((this._sha512.IsNullOrEmpty() || newOther._sha512.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512))) && ((this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512)))
{ {
dupefound = true; dupefound = true;
} }

View File

@@ -35,32 +35,32 @@ namespace SabreTools.Library.DatItems
} }
public string CRC public string CRC
{ {
get { return _crc.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_crc); } get { return _crc.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_crc); }
set { _crc = Utilities.StringToByteArray(value); } set { _crc = Utilities.StringToByteArray(value); }
} }
public string MD5 public string MD5
{ {
get { return _md5.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_md5); } get { return _md5.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_md5); }
set { _md5 = Utilities.StringToByteArray(value); } set { _md5 = Utilities.StringToByteArray(value); }
} }
public string SHA1 public string SHA1
{ {
get { return _sha1.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha1); } get { return _sha1.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha1); }
set { _sha1 = Utilities.StringToByteArray(value); } set { _sha1 = Utilities.StringToByteArray(value); }
} }
public string SHA256 public string SHA256
{ {
get { return _sha256.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha256); } get { return _sha256.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha256); }
set { _sha256 = Utilities.StringToByteArray(value); } set { _sha256 = Utilities.StringToByteArray(value); }
} }
public string SHA384 public string SHA384
{ {
get { return _sha384.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha384); } get { return _sha384.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha384); }
set { _sha384 = Utilities.StringToByteArray(value); } set { _sha384 = Utilities.StringToByteArray(value); }
} }
public string SHA512 public string SHA512
{ {
get { return _sha512.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha512); } get { return _sha512.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha512); }
set { _sha512 = Utilities.StringToByteArray(value); } set { _sha512 = Utilities.StringToByteArray(value); }
} }
public string Date public string Date
@@ -212,22 +212,22 @@ namespace SabreTools.Library.DatItems
} }
// If we can determine that the roms have no non-empty hashes in common, we return false // If we can determine that the roms have no non-empty hashes in common, we return false
if ((_crc.IsNullOrEmpty() || newOther._crc.IsNullOrEmpty()) if ((_crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace())
&& (this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty()) && (this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
&& (this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty()) && (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
&& (this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty()) && (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
&& (this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty()) && (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace())
&& (this._sha512.IsNullOrEmpty() || newOther._sha512.IsNullOrEmpty())) && (this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()))
{ {
dupefound = false; dupefound = false;
} }
else if ((this.Size == newOther.Size) else if ((this.Size == newOther.Size)
&& ((this._crc.IsNullOrEmpty() || newOther._crc.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._crc, newOther._crc)) && ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._crc, newOther._crc))
&& ((this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._md5, newOther._md5)) && ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
&& ((this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1)) && ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
&& ((this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256)) && ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
&& ((this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384)) && ((this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
&& ((this._sha512.IsNullOrEmpty() || newOther._sha512.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512))) && ((this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512)))
{ {
dupefound = true; dupefound = true;
} }

View File

@@ -102,7 +102,7 @@ namespace SabreTools.Library.FileTypes
string match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault(); string match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault();
// If we had a file, copy that over to the new name // If we had a file, copy that over to the new name
if (!String.IsNullOrEmpty(match)) if (!String.IsNullOrWhiteSpace(match))
{ {
realentry = match; realentry = match;
File.Copy(match, Path.Combine(outDir, entryName)); File.Copy(match, Path.Combine(outDir, entryName));
@@ -141,7 +141,7 @@ namespace SabreTools.Library.FileTypes
string match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault(); string match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault();
// If we had a file, copy that over to the new name // If we had a file, copy that over to the new name
if (!String.IsNullOrEmpty(match)) if (!String.IsNullOrWhiteSpace(match))
{ {
Utilities.TryOpenRead(match).CopyTo(ms); Utilities.TryOpenRead(match).CopyTo(ms);
realentry = match; realentry = match;
@@ -269,7 +269,7 @@ namespace SabreTools.Library.FileTypes
if (rom.Type == ItemType.Rom) if (rom.Type == ItemType.Rom)
{ {
if (date && !String.IsNullOrEmpty(((Rom)rom).Date)) if (date && !String.IsNullOrWhiteSpace(((Rom)rom).Date))
{ {
File.SetCreationTime(fileName, DateTime.Parse(((Rom)rom).Date)); File.SetCreationTime(fileName, DateTime.Parse(((Rom)rom).Date));
} }

View File

@@ -351,7 +351,7 @@ namespace SabreTools.Library.FileTypes
{ {
// Get temporary date-time if possible // Get temporary date-time if possible
DateTime? usableDate = null; DateTime? usableDate = null;
if (date && !String.IsNullOrEmpty(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt)) if (date && !String.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt))
{ {
usableDate = dt; usableDate = dt;
} }
@@ -404,7 +404,7 @@ namespace SabreTools.Library.FileTypes
// Get temporary date-time if possible // Get temporary date-time if possible
DateTime? usableDate = null; DateTime? usableDate = null;
if (date && !String.IsNullOrEmpty(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt)) if (date && !String.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out DateTime dt))
{ {
usableDate = dt; usableDate = dt;
} }
@@ -530,7 +530,7 @@ namespace SabreTools.Library.FileTypes
// Get temporary date-time if possible // Get temporary date-time if possible
DateTime? usableDate = null; DateTime? usableDate = null;
if (date && !String.IsNullOrEmpty(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out DateTime dt)) if (date && !String.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out DateTime dt))
{ {
usableDate = dt; usableDate = dt;
} }
@@ -590,7 +590,7 @@ namespace SabreTools.Library.FileTypes
{ {
// Get temporary date-time if possible // Get temporary date-time if possible
DateTime? usableDate = null; DateTime? usableDate = null;
if (date && !String.IsNullOrEmpty(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out DateTime dt)) if (date && !String.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out DateTime dt))
{ {
usableDate = dt; usableDate = dt;
} }

View File

@@ -81,7 +81,7 @@ namespace SabreTools.Library.FileTypes
zr = zf.OpenReadStream(i, false, out Stream readStream, out ulong streamsize, out SabreTools.Library.Data.CompressionMethod cm, out uint lastMod); zr = zf.OpenReadStream(i, false, out Stream readStream, out ulong streamsize, out SabreTools.Library.Data.CompressionMethod cm, out uint lastMod);
// Create the rest of the path, if needed // Create the rest of the path, if needed
if (!String.IsNullOrEmpty(Path.GetDirectoryName(zf.Entries[i].FileName))) if (!String.IsNullOrWhiteSpace(Path.GetDirectoryName(zf.Entries[i].FileName)))
{ {
Directory.CreateDirectory(Path.Combine(outDir, Path.GetDirectoryName(zf.Entries[i].FileName))); Directory.CreateDirectory(Path.Combine(outDir, Path.GetDirectoryName(zf.Entries[i].FileName)));
} }
@@ -465,7 +465,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length); ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !String.IsNullOrEmpty(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt)) if (date && !String.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.OpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, zipFile.OpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize,
@@ -536,7 +536,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(inputStream.Length); ulong istreamSize = (ulong)(inputStream.Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !String.IsNullOrEmpty(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt)) if (date && !String.IsNullOrWhiteSpace(rom.Date) && DateTime.TryParse(rom.Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.OpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize, zipFile.OpenWriteStream(false, false, rom.Name.Replace('\\', '/'), istreamSize,
@@ -686,7 +686,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[index]).Length); ulong istreamSize = (ulong)(new FileInfo(inputFiles[index]).Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !String.IsNullOrEmpty(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out dt)) if (date && !String.IsNullOrWhiteSpace(roms[index].Date) && DateTime.TryParse(roms[index].Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.OpenWriteStream(false, false, roms[index].Name.Replace('\\', '/'), istreamSize, zipFile.OpenWriteStream(false, false, roms[index].Name.Replace('\\', '/'), istreamSize,
@@ -763,7 +763,7 @@ namespace SabreTools.Library.FileTypes
ulong istreamSize = (ulong)(new FileInfo(inputFiles[-index - 1]).Length); ulong istreamSize = (ulong)(new FileInfo(inputFiles[-index - 1]).Length);
DateTime dt = DateTime.Now; DateTime dt = DateTime.Now;
if (date && !String.IsNullOrEmpty(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out dt)) if (date && !String.IsNullOrWhiteSpace(roms[-index - 1].Date) && DateTime.TryParse(roms[-index - 1].Date.Replace('\\', '/'), out dt))
{ {
uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt); uint msDosDateTime = Utilities.ConvertDateTimeToMsDosTimeFormat(dt);
zipFile.OpenWriteStream(false, false, roms[-index - 1].Name.Replace('\\', '/'), istreamSize, zipFile.OpenWriteStream(false, false, roms[-index - 1].Name.Replace('\\', '/'), istreamSize,

View File

@@ -376,9 +376,9 @@ namespace SabreTools.Library.Skippers
foreach (Skipper skipper in tempList) foreach (Skipper skipper in tempList)
{ {
// If we're searching for the skipper OR we have a match to an inputted one // If we're searching for the skipper OR we have a match to an inputted one
if (String.IsNullOrEmpty(skipperName) if (String.IsNullOrWhiteSpace(skipperName)
|| (!String.IsNullOrEmpty(skipper.Name) && skipperName.ToLowerInvariant() == skipper.Name.ToLowerInvariant()) || (!String.IsNullOrWhiteSpace(skipper.Name) && skipperName.ToLowerInvariant() == skipper.Name.ToLowerInvariant())
|| (!String.IsNullOrEmpty(skipper.Name) && skipperName.ToLowerInvariant() == skipper.SourceFile.ToLowerInvariant())) || (!String.IsNullOrWhiteSpace(skipper.Name) && skipperName.ToLowerInvariant() == skipper.SourceFile.ToLowerInvariant()))
{ {
// Loop through the rules until one is found that works // Loop through the rules until one is found that works
BinaryReader br = new BinaryReader(input); BinaryReader br = new BinaryReader(input);

View File

@@ -242,7 +242,7 @@ namespace SabreTools.Library.Tools
public static string CleanHashData(string hash, int padding) public static string CleanHashData(string hash, int padding)
{ {
// If we have a known blank hash, return blank // If we have a known blank hash, return blank
if (string.IsNullOrEmpty(hash) || hash == "-" || hash == "_") if (string.IsNullOrWhiteSpace(hash) || hash == "-" || hash == "_")
{ {
return ""; return "";
} }
@@ -251,7 +251,7 @@ namespace SabreTools.Library.Tools
hash = hash.Trim().Replace("0x", ""); hash = hash.Trim().Replace("0x", "");
// If we have a blank hash now, return blank // If we have a blank hash now, return blank
if (string.IsNullOrEmpty(hash)) if (string.IsNullOrWhiteSpace(hash))
{ {
return ""; return "";
} }
@@ -1862,6 +1862,32 @@ namespace SabreTools.Library.Tools
.ToArray()); .ToArray());
} }
/// <summary>
/// Ensure the output directory is a proper format and can be created
/// </summary>
/// <param name="outDir">Output directory to check</param>
/// <param name="create">True if the output directory should be created, false otherwise (default)</param>
/// <returns>Full path to the proper output directory</returns>
public static string EnsureOutputDirectory(string outDir, bool create = false)
{
// If the output directory is invalid
if (string.IsNullOrWhiteSpace(outDir))
{
outDir = Environment.CurrentDirectory;
}
// Get the full path for the output directory
outDir = Path.GetFullPath(outDir);
// If we're creating the output folder, do so
if (create)
{
Directory.CreateDirectory(outDir);
}
return outDir;
}
/// <summary> /// <summary>
/// Get a proper romba sub path /// Get a proper romba sub path
/// </summary> /// </summary>
@@ -2244,7 +2270,7 @@ namespace SabreTools.Library.Tools
/// <param name="array">The array to test</param> /// <param name="array">The array to test</param>
/// <returns>true if the array parameter is null or has a length of zero; otherwise, false.</returns> /// <returns>true if the array parameter is null or has a length of zero; otherwise, false.</returns>
/// <link>https://stackoverflow.com/questions/8560106/isnullorempty-equivalent-for-array-c-sharp</link> /// <link>https://stackoverflow.com/questions/8560106/isnullorempty-equivalent-for-array-c-sharp</link>
public static bool IsNullOrEmpty(this Array array) public static bool IsNullOrWhiteSpace(this Array array)
{ {
return (array == null || array.Length == 0); return (array == null || array.Length == 0);
} }

View File

@@ -125,7 +125,7 @@ namespace SabreTools
}; };
// Clean the temp directory // Clean the temp directory
tempDir = (String.IsNullOrEmpty(tempDir) ? Path.GetTempPath() : tempDir); tempDir = (String.IsNullOrWhiteSpace(tempDir) ? Path.GetTempPath() : tempDir);
// For each input directory, create a DAT // For each input directory, create a DAT
foreach (string path in inputs) foreach (string path in inputs)
@@ -542,7 +542,7 @@ namespace SabreTools
{ {
// Set the special flags // Set the special flags
ForceMerging fm = ForceMerging.None; ForceMerging fm = ForceMerging.None;
if (!String.IsNullOrEmpty(forcemerge)) if (!String.IsNullOrWhiteSpace(forcemerge))
{ {
switch (forcemerge.ToLowerInvariant()) switch (forcemerge.ToLowerInvariant())
{ {
@@ -562,7 +562,7 @@ namespace SabreTools
} }
ForceNodump fn = ForceNodump.None; ForceNodump fn = ForceNodump.None;
if (!String.IsNullOrEmpty(forcend)) if (!String.IsNullOrWhiteSpace(forcend))
{ {
switch (forcend.ToLowerInvariant()) switch (forcend.ToLowerInvariant())
{ {
@@ -585,7 +585,7 @@ namespace SabreTools
} }
ForcePacking fp = ForcePacking.None; ForcePacking fp = ForcePacking.None;
if (!String.IsNullOrEmpty(forcepack)) if (!String.IsNullOrWhiteSpace(forcepack))
{ {
switch (forcepack.ToLowerInvariant()) switch (forcepack.ToLowerInvariant())
{ {

View File

@@ -149,7 +149,7 @@ namespace SabreTools
header = null, header = null,
homepage = null, homepage = null,
name = null, name = null,
outDir = Environment.CurrentDirectory, outDir = null,
postfix = "", postfix = "",
prefix = "", prefix = "",
repext = "", repext = "",