[DatFile] Make sure that error shows in correct place

This commit is contained in:
Matt Nadareski
2017-02-03 12:32:31 -08:00
parent 1bb485c938
commit b52e057d8b
3 changed files with 18 additions and 64 deletions

View File

@@ -292,13 +292,10 @@ namespace SabreTools.Helper.Dats
? Path.GetFileName(split[0]) ? Path.GetFileName(split[0])
: (Path.GetDirectoryName(split[0]).Remove(0, split[1].Length))); : (Path.GetDirectoryName(split[0]).Remove(0, split[1].Length)));
// If we have more than 0 roms, output // Try to output the file
if (outDats[j].Count > 0)
{
outDats[j].WriteToFile(path, logger); outDats[j].WriteToFile(path, logger);
} }
} }
}
logger.User("Outputting complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff")); logger.User("Outputting complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
} }
@@ -394,12 +391,9 @@ namespace SabreTools.Helper.Dats
: (Path.GetDirectoryName(split[0]).Remove(0, split[1].Length))); ; : (Path.GetDirectoryName(split[0]).Remove(0, split[1].Length))); ;
} }
// If we have more than 0 roms, output // Try to output the file
if (outDats[j].Count > 0)
{
outDats[j].WriteToFile(path, logger); outDats[j].WriteToFile(path, logger);
} }
}
logger.User("Outputting complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff")); logger.User("Outputting complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
} }
@@ -436,12 +430,9 @@ namespace SabreTools.Helper.Dats
} }
} }
// Output a DAT only if there are roms // Try to output the file
if (Count != 0)
{
WriteToFile(outDir, logger); WriteToFile(outDir, logger);
} }
}
/// <summary> /// <summary>
/// Convert, update, and filter a DAT file or set of files using a base /// Convert, update, and filter a DAT file or set of files using a base
@@ -483,12 +474,9 @@ namespace SabreTools.Helper.Dats
root, logger, true, clean, softlist, root, logger, true, clean, softlist,
keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0)); keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0));
// If we have roms, output them // Try to output the file
if (innerDatdata.Count != 0)
{
innerDatdata.WriteToFile((outDir == "" ? Path.GetDirectoryName(inputFileName) : outDir), logger, overwrite: (outDir != "")); innerDatdata.WriteToFile((outDir == "" ? Path.GetDirectoryName(inputFileName) : outDir), logger, overwrite: (outDir != ""));
} }
}
else if (Directory.Exists(inputFileName)) else if (Directory.Exists(inputFileName))
{ {
inputFileName = Path.GetFullPath(inputFileName) + Path.DirectorySeparatorChar; inputFileName = Path.GetFullPath(inputFileName) + Path.DirectorySeparatorChar;
@@ -503,11 +491,8 @@ namespace SabreTools.Helper.Dats
trim, single, root, logger, true, clean, softlist, trim, single, root, logger, true, clean, softlist,
keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0)); keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0));
// If we have roms, output them // Try to output the file
if (innerDatdata.Count > 0)
{
innerDatdata.WriteToFile((outDir == "" ? Path.GetDirectoryName(file) : outDir + Path.GetDirectoryName(file).Remove(0, inputFileName.Length - 1)), logger, overwrite: (outDir != "")); innerDatdata.WriteToFile((outDir == "" ? Path.GetDirectoryName(file) : outDir + Path.GetDirectoryName(file).Remove(0, inputFileName.Length - 1)), logger, overwrite: (outDir != ""));
}
}); });
} }
else else

View File

@@ -901,7 +901,6 @@ namespace SabreTools.Helper.Dats
matched.DatFormat = DatFormat.Logiqx; matched.DatFormat = DatFormat.Logiqx;
// If we are checking hashes only, essentially diff the inputs // If we are checking hashes only, essentially diff the inputs
bool found = false;
if (hashOnly) if (hashOnly)
{ {
// First we need to sort by hash to get duplicates // First we need to sort by hash to get duplicates
@@ -915,7 +914,6 @@ namespace SabreTools.Helper.Dats
{ {
if (rom.SourceID == 99) if (rom.SourceID == 99)
{ {
found = true;
if (rom.Type == ItemType.Disk || rom.Type == ItemType.Rom) if (rom.Type == ItemType.Disk || rom.Type == ItemType.Rom)
{ {
matched.Add(((Disk)rom).SHA1, rom); matched.Add(((Disk)rom).SHA1, rom);
@@ -935,7 +933,6 @@ namespace SabreTools.Helper.Dats
{ {
if (rom.SourceID == 99) if (rom.SourceID == 99)
{ {
found = true;
matched.Add(rom.Size + "-" + rom.CRC, rom); matched.Add(rom.Size + "-" + rom.CRC, rom);
} }
} }
@@ -943,14 +940,7 @@ namespace SabreTools.Helper.Dats
} }
// Now output the fixdat to the main folder // Now output the fixdat to the main folder
if (found) success &= matched.WriteToFile("", logger, stats: true);
{
matched.WriteToFile("", logger, stats: true);
}
else
{
logger.User("No fixDat needed");
}
return success; return success;
} }

View File

@@ -299,22 +299,10 @@ namespace SabreTools.Helper.Dats
// Now, output all of the files to the output directory // Now, output all of the files to the output directory
logger.User("DAT information created, outputting new files"); logger.User("DAT information created, outputting new files");
bool success = true; bool success = true;
if (nodump.Count > 0)
{
success &= nodump.WriteToFile(outDir, logger); success &= nodump.WriteToFile(outDir, logger);
}
if (sha1.Count > 0)
{
success &= sha1.WriteToFile(outDir, logger); success &= sha1.WriteToFile(outDir, logger);
}
if (md5.Count > 0)
{
success &= md5.WriteToFile(outDir, logger); success &= md5.WriteToFile(outDir, logger);
}
if (crc.Count > 0)
{
success &= crc.WriteToFile(outDir, logger); success &= crc.WriteToFile(outDir, logger);
}
return success; return success;
} }
@@ -547,18 +535,9 @@ namespace SabreTools.Helper.Dats
// Now, output all of the files to the output directory // Now, output all of the files to the output directory
logger.User("DAT information created, outputting new files"); logger.User("DAT information created, outputting new files");
bool success = true; bool success = true;
if (romdat.Count > 0)
{
success &= romdat.WriteToFile(outDir, logger); success &= romdat.WriteToFile(outDir, logger);
}
if (diskdat.Count > 0)
{
success &= diskdat.WriteToFile(outDir, logger); success &= diskdat.WriteToFile(outDir, logger);
}
if (sampledat.Count > 0)
{
success &= sampledat.WriteToFile(outDir, logger); success &= sampledat.WriteToFile(outDir, logger);
}
return success; return success;
} }