Null items are no fun

This commit is contained in:
Matt Nadareski
2020-07-19 12:57:13 -07:00
parent 334e1c4585
commit 9c7b044e93
3 changed files with 8 additions and 4 deletions

View File

@@ -63,7 +63,7 @@ namespace SabreTools.Library.DatFiles
EnsureKey(key); EnsureKey(key);
// Now return the value // Now return the value
return Items[key]; return Items[key].Where(i => i != null).ToList();
} }
} }

View File

@@ -295,6 +295,10 @@ namespace SabreTools.Library.DatFiles
/// <param name="item">Item to remove info for</param> /// <param name="item">Item to remove info for</param>
public void RemoveItem(DatItem item) public void RemoveItem(DatItem item)
{ {
// If we have a null item, we can't do anything
if (item == null)
return;
// No matter what the item is, we increate the count // No matter what the item is, we increate the count
lock (_lockObject) lock (_lockObject)
{ {

View File

@@ -47,7 +47,7 @@ namespace SabreTools.Library.Tools
{ {
string filename = Path.GetFileName(path); string filename = Path.GetFileName(path);
if (sanitize) if (sanitize)
filename.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-'); filename = filename.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-');
return filename; return filename;
} }
@@ -61,7 +61,7 @@ namespace SabreTools.Library.Tools
{ {
string filename = Path.GetFileName(child); string filename = Path.GetFileName(child);
if (sanitize) if (sanitize)
filename.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-'); filename = filename.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-');
return filename; return filename;
} }
@@ -71,7 +71,7 @@ namespace SabreTools.Library.Tools
{ {
string filename = child.Remove(0, parent.Length + 1); string filename = child.Remove(0, parent.Length + 1);
if (sanitize) if (sanitize)
filename.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-'); filename = filename.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-');
return filename; return filename;
} }