mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] Take care of possible null strings
This commit is contained in:
@@ -2196,7 +2196,7 @@ namespace SabreTools.Library.DatFiles
|
||||
string filename = inputs[newItem.SystemID].Split('¬')[0];
|
||||
string rootpath = inputs[newItem.SystemID].Split('¬')[1];
|
||||
|
||||
rootpath += (rootpath == "" ? "" : Path.DirectorySeparatorChar.ToString());
|
||||
rootpath += (String.IsNullOrWhiteSpace(rootpath) ? "" : Path.DirectorySeparatorChar.ToString());
|
||||
filename = filename.Remove(0, rootpath.Length);
|
||||
newItem.MachineName = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
|
||||
+ Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar
|
||||
@@ -3584,7 +3584,7 @@ namespace SabreTools.Library.DatFiles
|
||||
string romname = "";
|
||||
|
||||
// If the parent is blank, then we have a non-archive file
|
||||
if (parent == "")
|
||||
if (String.IsNullOrWhiteSpace(parent))
|
||||
{
|
||||
// If we have a SuperDAT, we want anything that's not the base path as the game, and the file as the rom
|
||||
if (Type == "SuperDAT")
|
||||
|
||||
@@ -570,7 +570,7 @@ namespace SabreTools.Library.DatFiles
|
||||
if (superdat && !keep)
|
||||
{
|
||||
string tempout = Regex.Match(machine.Name, @".*?\\(.*)").Groups[1].Value;
|
||||
if (tempout != "")
|
||||
if (!String.IsNullOrWhiteSpace(tempout))
|
||||
{
|
||||
machine.Name = tempout;
|
||||
}
|
||||
@@ -994,11 +994,11 @@ namespace SabreTools.Library.DatFiles
|
||||
superdat = true;
|
||||
if (keep)
|
||||
{
|
||||
Type = (Type == "" ? "SuperDAT" : Type);
|
||||
Type = (String.IsNullOrWhiteSpace(Type) ? "SuperDAT" : Type);
|
||||
}
|
||||
|
||||
string foldername = (xtr.GetAttribute("name") ?? "");
|
||||
if (foldername != "")
|
||||
if (!String.IsNullOrWhiteSpace(foldername))
|
||||
{
|
||||
parent.Add(foldername);
|
||||
}
|
||||
@@ -1099,7 +1099,7 @@ namespace SabreTools.Library.DatFiles
|
||||
if (!keep || !superdat)
|
||||
{
|
||||
string tempout = Regex.Match(dir.Name, @".*?\\(.*)").Groups[1].Value;
|
||||
if (tempout != "")
|
||||
if (!String.IsNullOrWhiteSpace(tempout))
|
||||
{
|
||||
dir.Name = tempout;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace SabreTools.Library.DatFiles
|
||||
if (rom.Type == ItemType.Rom)
|
||||
{
|
||||
// We can only write out if there's a SHA-1
|
||||
if (((Rom)rom).SHA1 != "")
|
||||
if (!String.IsNullOrWhiteSpace(((Rom)rom).SHA1))
|
||||
{
|
||||
name = ((Rom)rom).SHA1.Substring(0, 2)
|
||||
+ "/" + ((Rom)rom).SHA1.Substring(2, 2)
|
||||
@@ -253,7 +253,7 @@ namespace SabreTools.Library.DatFiles
|
||||
else if (rom.Type == ItemType.Disk)
|
||||
{
|
||||
// We can only write out if there's a SHA-1
|
||||
if (((Disk)rom).SHA1 != "")
|
||||
if (!String.IsNullOrWhiteSpace(((Disk)rom).SHA1))
|
||||
{
|
||||
name = ((Disk)rom).SHA1.Substring(0, 2)
|
||||
+ "/" + ((Disk)rom).SHA1.Substring(2, 2)
|
||||
@@ -269,7 +269,7 @@ namespace SabreTools.Library.DatFiles
|
||||
else
|
||||
{
|
||||
name = (UseGame ? rom.MachineName : rom.Name);
|
||||
if (ReplaceExtension != "" || RemoveExtension)
|
||||
if (!String.IsNullOrWhiteSpace(ReplaceExtension) || RemoveExtension)
|
||||
{
|
||||
if (RemoveExtension)
|
||||
{
|
||||
@@ -280,7 +280,7 @@ namespace SabreTools.Library.DatFiles
|
||||
dir = (dir.StartsWith(Path.DirectorySeparatorChar.ToString()) ? dir.Remove(0, 1) : dir);
|
||||
name = Path.Combine(dir, Path.GetFileNameWithoutExtension(name) + ReplaceExtension);
|
||||
}
|
||||
if (AddExtension != "")
|
||||
if (!String.IsNullOrWhiteSpace(AddExtension))
|
||||
{
|
||||
name += AddExtension;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
case "Rom.Name":
|
||||
case "Disk.Name":
|
||||
name = value == "" ? name : value;
|
||||
name = String.IsNullOrWhiteSpace(value) ? name : value;
|
||||
break;
|
||||
case "DatItem.Size":
|
||||
if (!Int64.TryParse(value, out size))
|
||||
|
||||
Reference in New Issue
Block a user