[DatFile, SimpleSort, FileTools] Make sure extensions are checked properly

This commit is contained in:
Matt Nadareski
2016-09-26 17:36:25 -07:00
parent f7e47d3cac
commit 219d6f7664
3 changed files with 12 additions and 4 deletions

View File

@@ -1189,7 +1189,11 @@ namespace SabreTools.Helper
{ {
// Check the file extension first as a safeguard // Check the file extension first as a safeguard
string ext = Path.GetExtension(filename).ToLowerInvariant(); string ext = Path.GetExtension(filename).ToLowerInvariant();
if (ext != ".txt" && ext != ".dat" && ext != ".xml") if (ext.StartsWith("."))
{
ext = ext.Substring(1);
}
if (ext != "txt" && ext != "dat" && ext != "xml")
{ {
return; return;
} }
@@ -3013,7 +3017,7 @@ namespace SabreTools.Helper
if (stats) if (stats)
{ {
StreamWriter sw = new StreamWriter(new MemoryStream()); StreamWriter sw = new StreamWriter(new MemoryStream());
OutputStats(sw, StatOutputFormat.None, logger, (RomCount + DiskCount == 0)); OutputStats(sw, StatOutputFormat.None, logger, recalculate: (RomCount + DiskCount == 0), baddumpCol: true, nodumpCol: true);
sw.Dispose(); sw.Dispose();
} }

View File

@@ -263,7 +263,7 @@ namespace SabreTools.Helper
Console.SetCursorPosition(0, Constants.HeaderHeight + 1); Console.SetCursorPosition(0, Constants.HeaderHeight + 1);
_logger.User("Stats of the matched ROMs:"); _logger.User("Stats of the matched ROMs:");
StreamWriter sw = new StreamWriter(new MemoryStream()); StreamWriter sw = new StreamWriter(new MemoryStream());
_matched.OutputStats(sw, StatOutputFormat.None, _logger, true); _matched.OutputStats(sw, StatOutputFormat.None, _logger, recalculate: true, baddumpCol: true, nodumpCol: true);
sw.Dispose(); sw.Dispose();
// Now output the fixdat based on the original input if asked // Now output the fixdat based on the original input if asked

View File

@@ -22,7 +22,11 @@ namespace SabreTools.Helper
{ {
// Limit the output formats based on extension // Limit the output formats based on extension
string ext = Path.GetExtension(filename).ToLowerInvariant(); string ext = Path.GetExtension(filename).ToLowerInvariant();
if (ext != ".dat" && ext != ".xml") if (ext.StartsWith("."))
{
ext = ext.Substring(1);
}
if (ext != "dat" && ext != "xml")
{ {
return 0; return 0;
} }