Create a 0-byte file for formats that don't allow actual blank folders

This commit is contained in:
Matt Nadareski
2016-05-20 09:56:49 -07:00
parent 26a2511701
commit daa41d1923

View File

@@ -10,6 +10,12 @@ namespace SabreTools.Helper
{ {
public class Output public class Output
{ {
// 0-byte file constants
public static long SizeZero = 0;
public static string CRCZero = "00000000";
public static string MD5Zero = "d41d8cd98f00b204e9800998ecf8427e";
public static string SHA1Zero = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
/// <summary> /// <summary>
/// Create and open an output file for writing direct from a dictionary /// Create and open an output file for writing direct from a dictionary
/// </summary> /// </summary>
@@ -156,8 +162,10 @@ namespace SabreTools.Helper
List<string> splitpath = new List<string>(); List<string> splitpath = new List<string>();
foreach (List<RomData> roms in sortable.Values) foreach (List<RomData> roms in sortable.Values)
{ {
foreach (RomData rom in roms) for (int index = 0; index < roms.Count; index++)
{ {
RomData rom = roms[index];
string state = ""; string state = "";
List<string> newsplit = rom.Game.Split('\\').ToList(); List<string> newsplit = rom.Game.Split('\\').ToList();
@@ -233,14 +241,32 @@ namespace SabreTools.Helper
} }
} }
// If we have a "null" game (created by DATFromDir or something similar), skip trying to add a rom // If we have a "null" game (created by DATFromDir or something similar), log it to file
if (rom.Name == "null" && rom.Size == -1 && rom.CRC == "null" && rom.MD5 == "null" && rom.SHA1 == "null") if (rom.Name == "null" && rom.Size == -1 && rom.CRC == "null" && rom.MD5 == "null" && rom.SHA1 == "null")
{ {
logger.Log("Empty folder found: " + rom.Game); logger.Log("Empty folder found: " + rom.Game);
// If we're in a mode that doesn't allow for actual empty folders, add the blank info
if (datdata.OutputFormat != OutputFormat.SabreDat && datdata.OutputFormat != OutputFormat.MissFile)
{
rom.Name = "-";
rom.Size = SizeZero;
rom.CRC = CRCZero;
rom.MD5 = MD5Zero;
rom.SHA1 = SHA1Zero;
} }
// Otherwise, output the rom data
// Otherwise, set the new path and such, write out, and continue
else else
{ {
splitpath = newsplit;
lastgame = rom.Game;
sw.Write(state);
continue;
}
}
// Now, output the rom data
switch (datdata.OutputFormat) switch (datdata.OutputFormat)
{ {
case OutputFormat.ClrMamePro: case OutputFormat.ClrMamePro:
@@ -328,7 +354,6 @@ namespace SabreTools.Helper
"/>\n"; "/>\n";
break; break;
} }
}
splitpath = newsplit; splitpath = newsplit;
lastgame = rom.Game; lastgame = rom.Game;